Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Overview

CryENGINE CRYENGINE comes with a localization system that allows text localization for the UI.
http://doc.mycryengine.com/display/SDKDOC3/LocalizationThe Localization System is documented within the Asset Creation Manual.

Besides string localization it is also possible to use different font and glyph sets for each language.

Table of Contents

...

maxLevel

...

3

...

minLevel

...

2

...

exclude

...

Overview

...

Basic folder structure

...

Basic Folder Structure

Folder

Packaged location

Description

GameSDK\Libs\

...

*.gfx

...

GameSDK\GameData.pak

Flash assets

Localization\<language>\HUD_Font_LocFont.gfx

Localization\<language>_XML.pak

Font lib for each language

  Localization\<language>\text_ui_*.xml
Localization\<language>_XML.pak

Translated strings

String Localization

UI string translations are stored in .xml excel Excel sheets. It simply stores labels (keys) and translation.

Translation table

The UI translation tables are located under Game\Languages\.xml*. The system loads all xml files in this folder on startup or on language change.
Translation tables for each language must be stored underGame: Localization\Localized\<Language>.pak\Languages\.xml*<Language>\text_ui*.xml for it to be processed to the default locations used by the engine.

For UI translation the tables must have a column "KEY", "ORIGINAL TEXT" and "TRANSLATED TEXT".

Pass

...

Localized String at Run-time

A label is also translated if it is passed as string to a dynamic textfield via: Code/\FlowGraph/\LUA.

Code Block
borderStyle
titleuielements.xmlnone
  <UIElement name="MyElement">

    <GFx file=" MyElement.gfx" layer="2" alpha="1" >
      <Constraints>
        <Align mode="fullscreen" />
      </Constraints>
    </GFx>

    <variables>
      <variable name=" MyTextbox " varname="_root.TextLayer.TextBox.text"/>
    </variables>

  </UIElement>
Code Block
titlecpp
borderStylenone
IFlashUIPtr pFlashUI = GetIFlashUIPtr();
If (pFlashUIif( NULL != pFlashUI )
{
   IUIElement* pElement = pFlashUI->GetUIElement("MyElement");
   if( NULL If!= (pElement)
   {
      pUIElement->SetVariable("MyTextbox", SUIArguments("@somelabel"));
   }
}

...

Font libraries and glyph sets

It is recommended to use one font library and glyph set for all flash assets. One reason is to save memory since you don't want to embed every font in every flash file. This technique also allows embedding different glyph sets for different languages.

It also makes sure that your corporate design is consistent over all UI assets and changes are even easier since it is only necessary to change two files one file per language to switch the font for the whole UI.

Setup

...

There are two files that are needed:

...

font

...

library

...

The gfxfontlib.gfx defines all your fonts that are used in your UI.

Since exported fonts in flash always hold every glyph for the chosen font it is necessary to create a gfxfontlib_glyphs.gfx file that allows embedding only the glyphs you want.

Setup gfxfontlib_glyphs.gfx

This file holds every glyph for every font that is used in the UI.
Create a new flash file and name it gfxfontlib_glyphs.fla.
Create Dynamic Textboxes on the stage for each font and font-style and embed the needed characters.

Image Removed

Create an empty dummy MovieClip and mark it for "Export for runtime sharing".

Image Removed

Export the gfxfontlib_glyphs.swf file with the following command:

Code Block
gfxexport.exe \-c \-i DDS \-share_images \-rescale hi  gfxfontlib_glyphs.swf

h3. Setup gfxfontlib.gfx

...

A font library is a GFX file that exports Action Script symbols describing a font, and contains the associated glyph data to render the font in the game.
When dynamic text is composed by the user, the glyphs will be loaded by Scaleform from this source file.

It is possible to set up a font library with more than one font (with different Action Script export names), but in the GameSDK sample we only use one.

In the GameSDK sample project, we use the library HUD_Font_LocFont.gfx file. The flash file used to generate this GFX in the SDK can be downloaded from here as a sample: HUD_Font_LocFont.flaHowever, you can create your own if you prefer to create a font library from scratch.

For each distinct font you wish to use, create new font symbols and set the font-style in the library (rightRight-click Click -> New font).

Go to the font's properties to set up the export settings.
Make sure to check both the export checkboxes, and set the Identifier to an unique name. This is the name will be used in flash files using this font.
The sharing URL should be set to the name of the final GFX file (with .)
Choose font and style, give it a name and mark "Export for runtime sharing"

Image Removed

Create an empty MovieClip and mark it as "import for runtime sharing" (or just copy and paste the dummy MovieClip from the gfxfontlib_glyphs.fla). This step is necessary to create a dependency to the glyph file.

Image Removed

Export the gfxfontlib.swf file with the following command:SWF extension)
Image Added 

After you set up all the fonts you wish to use in the UI, you should create localized copies of the font library for each language you wish to support.
The most optimized and efficient way to do this is to select a sub-set of glyphs that can be used in some language, and only export this set of glyphs for that specific language. This saves disk and memory space, as only the necessary glyphs will be available.

In the options dialog for the font, you can set the font groups to embed glyphs for. The glyphs will be processed from the given OS font and styles. 

Image Added 

After you finish setting up the fonts in the font library for a language, publish the flash file to .SWF
This should result in HUD_Font_LocFont.swf file for that specific language.

Now, use gfxexport tool to convert the font library to Scaleform GFX format.

Code Block
gfxexport.exe \-c \-i DDS \-share_images \-rescale hi \-strip_font_shapes gfxfontlib.swf

...

 HUD_Font_LocFont.swf

Make sure to copy the resulting GFX into your per-language localized asset file (so it eventually ends up in Localization/<language>_xml.pak for that language, for the default asset build script you would store it as Localization/<language/HUD_Font_LocFont.gfx)

These steps should be repeated for each language you want to support in your project that needs distinct glyph sets for it's fonts. Alternatively, you can only create one (large) font library and re-use it for each language.

Info

At runtime you have to reload the UI elements after switching to a different language to make sure the new glyphs take effect.

Import fonts to any flash asset

Finally you need to import the exported fonts from gfxfontlib.gfx to the font library into your flash assets. You can just copy and paste them.

Image Removed


You need to set up a font in the flash file's library, and mark it for import as seen here.
Enter the same Identifier for the font you exported in the font library GFX file, and set the import URL to the GFX file. 

Image Added

While authoring the flash file, you can use the imported font symbol in the library instead of referring to an OS font.
At runtime, this font will be loaded from the font library. 

Export your flash assets with the following command:

Code Block
gfxexport.exe \-c \-i DDS \-share_images \-rescale hi \-strip_font_shapes \*.swf
Code Block

To use the fonts on your textboxes just choose them in the font dropdown list.
Note, the * on the font means that the font resides in the font library. 

Image ModifiedNOTE:

Info

If you use translation labels for static textboxes you have to make them dynamic! Otherwise the translation doesn't work.

Different font libraries and glyph sets for different languages

Just create gfxfontlib.gfx and gfxfontlib_glyphs.gfx files for each language and place them under:

Game\Localized\<language>.pak\Libs\UI\

NOTE: you have to reload the UI elements after switch to a different language.