Система Flash UI/Локализация UI

Материал из CryWiki Russia

(Различия между версиями)
Перейти к: навигация, поиск
 
(3 промежуточные версии не показаны)
Строка 1: Строка 1:
-
CryENGINE comes with a localization system that allows text localization for the UI. The [SDKDOC3:Localization] System is documented within the Asset Creation Manual.
+
В CryENGINE встроена система локализации, которая позволяет локализировать текст UI. Система [[Локализация|локализации]] документирована в руководстве по созданию ресурсов.
-
Besides string localization it is also possible to use different font and glyph sets for each language.
+
Кроме того, строки локализации могут использовать различные шрифты и наборы глифов для каждого языка.
-
== Basic folder structure ==
+
== Базовая структура каталогов ==
{| class="crytable"
{| class="crytable"
-
! Folder !! Description
+
! Папка !! Описание
|-
|-
-
| Game\Libs\UI\*.gfx || Flash assets
+
| Game\Libs\UI\*.gfx || Flash-ассеты
|-
|-
-
| Game\Localized\<language>.pak\Libs\UI\gfxfontlib.gfx || Font lib for each language
+
| Game\Localized\<язык>.pak\Libs\UI\gfxfontlib.gfx || Библиотека шрифта для каждого языка
|-
|-
-
| Game\Localized\<language>.pak\Libs\UI\gfxfontlib_glyphs.gfx || Glyph set for each language
+
| width="350px" | Game\Localized\<язык>.pak\Libs\UI\gfxfontlib_glyphs.gfx || Набор глифов для каждого языка
|-
|-
-
| Game\Localized\<language>.pak\Languages\*.xml || Translation tables
+
| Game\Localized\<язык>.pak\Languages\*.xml || Таблицы перевода
|}
|}
-
== String Localization ==
+
== Строки локализации ==
-
UI string translations are stored in xml excel sheets. It simply stores labels (keys) and translation.
+
Строки локализации UI хранятся в электронной XML-таблице Microsoft Office Excel. Она просто хранит метки (ключи) и перевод.
-
== Translation table ==
+
== Таблица перевода ==
-
The UI translation tables are located under: {{Game\Languages.xml}}. The system loads all xml files in this folder on start-up or on language change.
+
Таблица перевода UI хранится в <tt>Game\Languages.xml</tt>. Система загружает все XML-файлы из этой папки при запуске или при смене языка.<br />
-
Translation tables for each language must be stored under: {{Game\Localized\<Language>.pak\Languages.xml}}.
+
Таблицs перевода для каждого языка должны быть сохранены в <tt>Game\Localized\<Язык>.pak\Languages.xml</tt>.<br />
-
For UI translation the tables must have a column *"KEY"*, *"ORIGINAL TEXT"* and *"TRANSLATED TEXT"*.
+
Для перевода UI в таблицах имеются колонки '''"KEY"''', '''"ORIGINAL TEXT"''' и '''"TRANSLATED TEXT"'''.
-
!translation.png!
+
[[Файлы:Translation.png]]
-
== Pass localized string at runtime ==
+
== Передача локализованной строки во время выполнения ==
-
A label is also translated if it is passed as string to a dynamic textfield via {{Code\FlowGraph\LUA}}.
+
Метки (''Label'') также подвергаются переводу, если они передаются как строки в динамические текстовые поля через <tt>Код\Flow Graph\LUA</tt>.
-
{code:title=uielements.xml} <UIElement name="MyElement">
+
{{Код|заголовок=UIElements.xml|блок=<source lang="xml"><UIElement name="MyElement">
-
<GFx file=" MyElement.gfx" layer="2" alpha="1" >
+
  <GFx file="MyElement.gfx" layer="2" alpha="1" >
-
<Constraints>
+
    <Constraints>
-
<Align mode="fullscreen" />
+
      <Align mode="fullscreen" />
-
</Constraints>
+
    </Constraints>
-
</GFx>
+
  </GFx>
-
<variables>
+
  <variables>
-
<variable name=" MyTextbox " varname="_root.TextLayer.TextBox.text"/>
+
    <variable name="MyTextbox" varname="_root.TextLayer.TextBox.text"/>
-
</variables>
+
  </variables>
-
</UIElement>
+
</UIElement></source>}}
-
{code}
+
-
{code:title=cpp}IFlashUIPtr pFlashUI = GetIFlashUIPtr();
+
{{Код|заголовок=C++|блок=<source lang="CPP">IFlashUIPtr pFlashUI = GetIFlashUIPtr();
If (pFlashUI)
If (pFlashUI)
{
{
-
IUIElement* pElement = pFlashUI->GetUIElement(“MyElement”);
+
  IUIElement* pElement = pFlashUI->GetUIElement("MyElement");
-
If (pElement)
+
  If (pElement)
-
pUIElement->SetVariable(“MyTextbox”, SUIArguments(@somelabel”));
+
      pUIElement->SetVariable("MyTextbox", SUIArguments("@любая_метка"));
-
}
+
}</source>}}
-
{code}
+
-
== Fontlibs 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.
+
Рекомендуется использовать '''одну''' библиотеку шрифтов и набор глифов для всех Flash-ассетов. Одна из причин — меньше требование памяти, поскольку вам не придётся встраивать каждый шрифт в каждый Flash-файл. Также этот метод позволяет встраивать различные наборы глифов в разные языки.
-
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 to switch the font for the whole UI.
+
Они также гарантируют, что вашему фирменному стилю будут соответствовать все ассеты UI, и изменить его легче простого, поскольку надо изменить всего лишь два файла для смены шрифта всего интерфейса.
-
=== Setup gfxfontlib and gfxfontlib_glyphs ====
+
=== Настройка gfxfontlib и gfxfontlib_glyphs ====
-
There are two files that are needed:
+
Понадобятся два файла:
-
* gfxfontlib.gfx - Font library.
+
* gfxfontlib.gfx - Библиотека шрифта.
-
* gfxfontlib_glyphs.gfx - Glyph set.
+
* gfxfontlib_glyphs.gfx - Набор глифов.
-
The *gfxfontlib.gfx* defines all your fonts that are used in your UI.
+
Файл '''gfxfontlib.gfx''' определяет все ваши шрифты, которые используются в вашем интерфейсе.
-
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.
+
Так как экспортированные шрифты в Flash всегда содержат каждый глиф для выбранного шрифта необходимо создать файл "gfxfontlib_glyphs.gfx'' ''', что позволит встраивать только те глифы, которые вы хотите.
-
=== Setup gfxfontlib_glyphs.gfx ===
+
=== Настройка gfxfontlib_glyphs.gfx ===
-
This file holds every glyph for every font that is used in the UI.
+
Этот файл содержит каждый глиф для каждого шрифта, используемого в UI.<br />
-
Create a new flash file and name it *gfxfontlib_glyphs.fla*.
+
Создайте новый Flash-файл и назовите его '''gfxfontlib_glyphs.fla'''.<br />
Create Dynamic Textboxes on the stage for each font and font-style and embed the needed characters.
Create Dynamic Textboxes on the stage for each font and font-style and embed the needed characters.
-
!glyph_file_1.png!
+
[[Файл:glyph_file_1.png]]
Create an empty dummy MovieClip and mark it for “Export for runtime sharing”.
Create an empty dummy MovieClip and mark it for “Export for runtime sharing”.
-
!glyph_file_2.png!
+
[[Файл:glyph_file_2.png]]
Export the gfxfontlib_glyphs.swf file with the following command:
Export the gfxfontlib_glyphs.swf file with the following command:
-
{code}gfxexport.exe -c -i DDS -share_images -rescale hi gfxfontlib_glyphs.swf
+
<code>gfxexport.exe -c -i DDS -share_images -rescale hi gfxfontlib_glyphs.swf</code>
-
{code}
+
=== Setup gfxfontlib.gfx ===
=== Setup gfxfontlib.gfx ===
-
This file defines all fonts and font-styles for the UI.
+
This file defines all fonts and font-styles for the UI.<br />
-
Create a new flash file and name it gfxfontlib.fla. Create new font symbols for each font and font-style in the library (*Right-Click -> New font*)
+
Create a new flash file and name it gfxfontlib.fla. Create new font symbols for each font and font-style in the library ('''Right-Click -> New font''').<br />
Choose font and style, give it a name and mark “Export for runtime sharing”
Choose font and style, give it a name and mark “Export for runtime sharing”
-
!fontlib_1.png!
+
[[Файл:fontlib_1.png]]
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.
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.
-
!fontlib_2.png!
+
[[Файл:fontlib_2.png]]
Export the gfxfontlib.swf file with the following command:
Export the gfxfontlib.swf file with the following command:
-
{code}gfxexport.exe -c -i DDS -share_images -rescale hi -strip_font_shapes gfxfontlib.swf
+
<code>gfxexport.exe -c -i DDS -share_images -rescale hi -strip_font_shapes gfxfontlib.swf</code>
-
{code}
+
=== Import fonts to any flash asset ===
=== Import fonts to any flash asset ===
Finally you need to import the exported fonts from gfxfontlib.gfx to your flash assets. You can just copy and paste them.
Finally you need to import the exported fonts from gfxfontlib.gfx to your flash assets. You can just copy and paste them.
-
!flash_asset1.png!
+
[[Файл:flash_asset1.png]]
Export your flash assets with the following command:
Export your flash assets with the following command:
-
{code}gfxexport.exe -c -i DDS -share_images -rescale hi -strip_font_shapes *.swf
+
<code>gfxexport.exe -c -i DDS -share_images -rescale hi -strip_font_shapes *.swf</code>
-
{code}
+
To use the fonts on your textboxes just choose them in the font dropdown list.
To use the fonts on your textboxes just choose them in the font dropdown list.
-
!flash_asset2.png!
+
[[Файл:flash_asset2.png]]
-
{info:title=Note}If you use translation labels for static textboxes you have to make them dynamic! Otherwise the translation doesn't work.{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 ==
== 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:
Just create *gfxfontlib.gfx* and *gfxfontlib_glyphs.gfx* files for each language and place them under:
-
{{Game\Localized\<language>.pak\Libs\UI}}
+
<tt>Game\Localized\<language>.pak\Libs\UI</tt>
-
{info:title=Note}You have to reload the UI elements after switching to a different language.{info}
+
{{Примечание|You have to reload the UI elements after switching to a different language.}}
 +
 
 +
 
 +
[[Категория:CryEngine 3 Free SDK:Пользовательский интерфейс]]

Текущая версия на 11:18, 28 сентября 2016

В CryENGINE встроена система локализации, которая позволяет локализировать текст UI. Система локализации документирована в руководстве по созданию ресурсов.

Кроме того, строки локализации могут использовать различные шрифты и наборы глифов для каждого языка.

Содержание

Базовая структура каталогов

Папка Описание
Game\Libs\UI\*.gfx Flash-ассеты
Game\Localized\<язык>.pak\Libs\UI\gfxfontlib.gfx Библиотека шрифта для каждого языка
Game\Localized\<язык>.pak\Libs\UI\gfxfontlib_glyphs.gfx Набор глифов для каждого языка
Game\Localized\<язык>.pak\Languages\*.xml Таблицы перевода

Строки локализации

Строки локализации UI хранятся в электронной XML-таблице Microsoft Office Excel. Она просто хранит метки (ключи) и перевод.

Таблица перевода

Таблица перевода UI хранится в Game\Languages.xml. Система загружает все XML-файлы из этой папки при запуске или при смене языка.
Таблицs перевода для каждого языка должны быть сохранены в Game\Localized\<Язык>.pak\Languages.xml.
Для перевода UI в таблицах имеются колонки "KEY", "ORIGINAL TEXT" и "TRANSLATED TEXT".

Файлы:Translation.png

Передача локализованной строки во время выполнения

Метки (Label) также подвергаются переводу, если они передаются как строки в динамические текстовые поля через Код\Flow Graph\LUA.

UIElements.xml
<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>


C++
IFlashUIPtr pFlashUI = GetIFlashUIPtr();
If (pFlashUI)
{
   IUIElement* pElement = pFlashUI->GetUIElement("MyElement");
   If (pElement)
      pUIElement->SetVariable("MyTextbox", SUIArguments("@любая_метка"));
}


Библиотеки шрифтов и наборы глифов

Рекомендуется использовать одну библиотеку шрифтов и набор глифов для всех Flash-ассетов. Одна из причин — меньше требование памяти, поскольку вам не придётся встраивать каждый шрифт в каждый Flash-файл. Также этот метод позволяет встраивать различные наборы глифов в разные языки.

Они также гарантируют, что вашему фирменному стилю будут соответствовать все ассеты UI, и изменить его легче простого, поскольку надо изменить всего лишь два файла для смены шрифта всего интерфейса.

Настройка gfxfontlib и gfxfontlib_glyphs =

Понадобятся два файла:

  • gfxfontlib.gfx - Библиотека шрифта.
  • gfxfontlib_glyphs.gfx - Набор глифов.

Файл gfxfontlib.gfx определяет все ваши шрифты, которые используются в вашем интерфейсе.

Так как экспортированные шрифты в Flash всегда содержат каждый глиф для выбранного шрифта необходимо создать файл "gfxfontlib_glyphs.gfx ', что позволит встраивать только те глифы, которые вы хотите.

Настройка gfxfontlib_glyphs.gfx

Этот файл содержит каждый глиф для каждого шрифта, используемого в UI.
Создайте новый Flash-файл и назовите его gfxfontlib_glyphs.fla.
Create Dynamic Textboxes on the stage for each font and font-style and embed the needed characters.

Файл:Glyph file 1.png

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

Файл:Glyph file 2.png

Export the gfxfontlib_glyphs.swf file with the following command:

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

Setup gfxfontlib.gfx

This file defines all fonts and font-styles for the UI.
Create a new flash file and name it gfxfontlib.fla. Create new font symbols for each font and font-style in the library (Right-Click -> New font).
Choose font and style, give it a name and mark “Export for runtime sharing”

Файл:Fontlib 1.png

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.

Файл:Fontlib 2.png

Export the gfxfontlib.swf file with the following command:

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

Import fonts to any flash asset

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

Файл:Flash asset1.png

Export your flash assets with the following command:

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

To use the fonts on your textboxes just choose them in the font dropdown list.

Файл:Flash asset2.png

Примечание:
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

Примечание:
You have to reload the UI elements after switching to a different language.