4.29.2014

Creating A Localization Ready Game in UE4: Part 1-Text

By Justin Sargent

Creating a localization ready game in Unreal Engine 4 is fortunately really simple.  Just follow this one basic rule and you’ll be set.

Use Text instead of String for any value ever displayed to the user.

Text is a new base type we’ve introduced into Unreal Engine 4 that handles internationalization and localization concerns for your game while abstracting all that into a concise, minimal package.

If you are creating a Blueprint just use Text literals and variables in graph and objects. Any text you type in can automatically be found, extracted and setup for translation by the engine.

Variable in Blueprints

If you’re a programmer, you need to use NSLOCTEXT macros anytime you put a display text literal in your code, or if you are creating a class/asset you should use an FText UProperty.

FText TestHUDText = NSLOCTEXT( "Your Namespace", "Your Key", "Your Text" )

Check out this documentation page for the details.

That’s it.

I bet you’re thinking ‘Wow! That seems really simple; there’s gotta be a catch. Localization is supposed to be hard.’ Well, there aren’t really any catches but some people will be tempted to cheat around this rule by converting between Text and String values.

Unfortunately, this is where you can run into problems. If you convert a String to a Text, that Text will be treated as culture invariant, aka it will not be translated. So it’s super important that you enter your display text in Text values initially. Converting a Text to a String is also not advised. Text values abstract away access to the direct String which allows for some great features such as live language toggling and provide you with guaranteed localization safe operations.

Now there are valid reasons to convert back-and-forth between Text and String but you need to be extra careful when doing this otherwise you’ll break localization for that aspect of your game. User input is in general a fine example of when it is ok to convert Text to String to do some additional processing, as the value is guaranteed to be culture invariant.

Another thing to be aware of is that though we’ve been working on the localization and internationalization systems for some time now, we still haven’t converted every single API in the engine to use the proper types. Please bear with our dust as we continue to improve the engine in this aspect, which will hopefully guide users to best practices.

We’d love to hear what you think about localization in UE4, so please drop by our forums!

Recent Posts

Datasmith and Unreal Engine Drive Real-time Architectural Design at Neoscape

Applying a real-time approach to strategy and branding in the real estate w...

Unreal Engine 4.19 Preview 1 Now Available

The first preview for Unreal Engine 4.19 is now available for download o

...

Epic Games Announces New Round of Unreal Dev Grants Totaling over $200,000

Chosen developers around the globe building independent games, tools and an...