Thread Tools Display Modes
Prev Previous Post   Next Post Next
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,989
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
 

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


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