How to add localization support

From ESOUI Wiki

Jump to: navigation, search

This is a collection of info for adding localization (multilingual) support to your addon.

There are several ways to do this, and this is just one method (that ZOS uses for its translations)

Contents

Addon structure

Separate each language to its own Lua file, preferably in a directory.

Then add the following to your addon manifest to load the strings:

path/lang/en.lua
path/lang/$(language).lua

This loads the English text as default, and then loads the other language if it's present. Note: it's important to have a default in light of the Spanish and Russian fan translation projects.

Creating strings

Translation works best if all the strings are separate from the actual display.

You can create strings in the standards ZOS localization with this function:

ZO_CreateStringId("GLOBALLY_UNIQUE_STRING_ID", "Translation")

The string ID must be unique. Prefix this with SI_YOUR_ADDON_NAME_ to make sure it's unique.

This function works by creating the string in a lookup table and then creates a global variable that has a number to identify which string it is.

Using Strings

Strings that you created with the string ID method can then be easily accessed throughout your addon.

The above example would be accessed with:

GetString( GLOBALLY_UNIQUE_STRING_ID )

Using string format functions

zo_formatstr lets you do advanced substitution in translations (see How to format strings with zo strformat).

Relevant forum threads:

http://www.esoui.com/forums/showthread.php?t=904

Getting Translations

If you can't translate yourself, ask in this forum:

This is all volunteer (just like addon programming), but it doesn't hurt to ask.

Testing

Rather than download a completely different client language, you can dynamically change the language ingame.

/script SetCVar("language.2", "de")

Replace "de" with the character code for the appropriate language you're testing.

Personal tools
Namespaces
Variants
Actions
Menu
Wiki
Toolbox