Thread Tools Display Modes
01/05/17, 08:59 AM   #1
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,912
Findig "ingame used" text values for reuse in your addons

Hey there,

after I've had to learn this in the past I'd like to share the knowledge about the ingame texts (strings) that we are able to reuse in our addons, and thus don't need to re-translate them with our own texts.

Find ingame used strings
To find some ingame texts you are able to search them in the ESOUI source code. The filename is located here:
Code:
esoui\ingamelocalization\localizegeneratedstrings.lua
-Download the esoui source code here for your local copy-

-Or browse through online at github-
-> -Direct link to the localizations file "localizegeneratedstrings.lua"-



Use ingame used strings in your addon
To use a string from the lua file you need the unique constant name from the array
"EsoStrings"

Code:
EsoStrings =
{
    "", -- Sync string for ClientKeyboardStrings first entry
    "English", -- SI_INPUT_LANGUAGE_ENGLISH
    "German", -- SI_INPUT_LANGUAGE_GERMAN
    "French", -- SI_INPUT_LANGUAGE_FRENCH
    "Japanese", -- SI_INPUT_LANGUAGE_JAPANESE
    "Unknown", -- SI_INPUT_LANGUAGE_UNKNOWN
    "Input Language Changed to: <<1>>", -- SI_ALERT_INPUT_LANGUAGE_CHANGE
    "Current Keyboard Layout: <<1>>", -- SI_KEYBIND_CURRENT_KEYBOARD_LAYOUT
    "Lua is reaching its memory limit.  You should consider disabling some addons and reloading the UI.", -- SI_LUA_LOW_MEMORY
    "Graphics Options", -- SI_WINDOW_TITLE_GRAPHICS_OPTIONS
    "Low", -- SI_LOW
    "High", -- SI_HIGH
...
}
The constants are written as a comment (starting with --) behind each string, e.g. SI_INPUT_LANGUAGE_ENGLISH or SI_WINDOW_TITLE_GRAPHICS_OPTIONS.

In your addon you're able to use this constant to get the localized string, depending on your game client's language then.
Use the following function
Code:
GetString(myStrings_SI_Constant)
The function can be used with an additional optional parameter2, but you need to set the parameter1 into "" then!
-> See description of param2 in post 2 of this thread
Code:
GetString("myStrings_SI_Constant", param2)

Example
In order to show the localized text for the chosen constant SI_INPUT_LANGUAGE_ENGLISH (will translate to "English", "Anglaise", "Englisch" depending on your game client's language)

Lua Code:
  1. local myLocalizedVariable = GetString(SI_INPUT_LANGUAGE_ENGLISH)
  2. --myLocalizedVariable  will contain the String "English" now

You're also able to use GetString() without assigning it to a local/global variable before.
This way you can use the game texts inside your LAM menus e.g. and don't have to think about translations (except the non standard game languages like Portuguese, Italian and so on)


Lua Code:
  1. --LAM optionsPanel array
  2. local optionsPanel = {
  3.        {
  4.             type = 'header',
  5.             name = GetString("SI_WINDOW_TITLE_GRAPHICS_OPTIONS"),
  6.         },
  7. ...
  8. }

Last edited by Baertram : 01/05/17 at 10:42 AM.
  Reply With Quote
01/05/17, 09:39 AM   #2
sirinsidiator
 
sirinsidiator's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 1,566
Nice writeup. Two small additions:
You don't need to pass the stringId as a string, unless you want to use the second argument to GetString:

Lua Code:
  1. GetString("SI_ITEMTYPE0") -- works
  2. GetString(SI_ITEMTYPE0) -- works
  3. GetString(SI_ITEMTYPE, ITEMTYPE_NONE) -- doesn't work
  4. GetString("SI_ITEMTYPE", ITEMTYPE_NONE) -- works

You can directly assign the stringId in LAM since a few versions ago:
Lua Code:
  1. --LAM optionsPanel array
  2.     local optionsPanel = {
  3.            {
  4.                 type = 'header',
  5.                 name = SI_WINDOW_TITLE_GRAPHICS_OPTIONS,
  6.             },
  7.     ...
  8.     }
  Reply With Quote
08/11/17, 03:04 AM   #3
Carter_DC
 
Carter_DC's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2014
Posts: 18
Hi, there.

And if i want, let's say not to add my own translations to each single area name in the game ?
where do i find the constants for area names used for localization, cuz it seems to me they aren't in this file ?
  Reply With Quote
08/11/17, 03:57 AM   #4
sirinsidiator
 
sirinsidiator's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 1,566
There are a lot of strings that are not defined in Lua. Some of them can be received via the API, but a lot of them are just not accessible.

In the case of zone names (if that is what you mean with areas), you can get a name for a zoneId via the GetZoneNameById api function. To get the zoneId of the map you are looking at, you can use GetCurrentMapZoneIndex and GetZoneId (on the return value).
  Reply With Quote
08/11/17, 05:31 AM   #5
Ayantir
 
Ayantir's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 1,019
I would also add that you can add those constants in XML files, such as

Lua Code:
  1. <Label name="something" text="SI_YES" />

It will display Yes or its translation in your UI.
  Reply With Quote

ESOUI » Developer Discussions » Tutorials & Other Helpful Info » Findig "ingame used" text values for reuse in your addons

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off