13
Localization Tutorial
HarpyWar edited this page 2014-07-20 00:12:10 -07:00
Files that are needed for localization are in root of the directory i18n. They must be saved with the same names in a specified language directory:
bnhelp.conf
bnmotd.txt
chathelp-war3.txt
common.xml
newaccount.txt
termsofservice.txt
w3motd.txt
Supported languages are: English
, Russian
, German
, Czech
, Spanish
, French
, Italian
, Japanese
, Korean
, Polish
, Chinese
. Please let us know if you have a game client with other language.
All files are plain text, except common.xml
— it contains hardcoded strings. Next tips related to this file.
- You can save original sequence of arguments:
<original>hello {} world {}/{}/{}</original> <!-- hello my world one/two/three -->
<translate>привет {} мир{}/{}/{}</translate> <!-- привет my мир one/two/three -->
- Or swap argument positions:
<original>hello {} world {}/{}/{}</original> <!-- hello my world one/two/three -->
<translate>привет {1} мир{3}/{2}/{0}</translate> <!-- привет one мир three/two/my -->
refid="123"
in<translate refid="123" />
means that translation refers to the duplicate string<string id="123">...</string>
. Actually you can ignore these lines, or add your own references if your translations are duplicates.- When you edit strings, you have to replace next symbols if they were added (update utility replaces it automatically for new strings):
<
→<
,>
→>
,\"
→"
- If you need to display braces then use double braces (
{{}}
will output{}
) - If you are changed > 5% of the text in
common.xml
then you can add your author name in<authors>
section. This is not used anywhere, just a hall of fame. - If you edit any localized hardcoded string in
*.cpp
,*.h
,*.lua
, you have to edit that string in section of allcommon.xml
files. - If you add a new localized hardcoded string in
*.cpp
,*.h
,*.lua
, you have to run utility fromscripts\localize\update.bat
— it will correctly update allcommon.xml
files, and new string will be added. Then find not-translated string in text-editor by<translate> </translate>
- Use pvpgn_localize_validator.exe to validate XML translation file (it needs installed Microsoft.NET Framework 4.0)
- Text identical in
termsofservice.txt
andnewaccount.txt
, so a translation can be duplicated. Text fromtermsofservice.txt
relates to all games butnewaccount.txt
only displays in Warcraft 3 in additional screen when creating a new account. news.txt
need not to be translated- Developers must use double quotes in Lua scripts (not single quotes) in localize function:
a = localize(username, "hello \"{}\"", "world") -- correct
b = localize(username, 'hello "{}"', "world") -- incorrect