WoW:USERAPI LocalizedClassNames: Difference between revisions

From AddOn Studio
Jump to navigation Jump to search
No edit summary
 
mNo edit summary
Line 1: Line 1:
{{userfunc}}
{{userfunc}}
__NOTOC__
Provides a table of class names in the user's locale.  Keys are in enUS, values in the current locale.
Provides a table of class names in the user's locale.  Keys are in enUS, values in the current locale.



Revision as of 07:31, 18 May 2020

This page documents a user-defined function that you can copy and paste into your addon. Replace PREFIX with your addon or lib prefix to avoid conflicts between different versions of these functions.

User defined functions

Provides a table of class names in the user's locale. Keys are in enUS, values in the current locale.

local locale = GetLocale()
-- Localized class names.  Index == enUS, value == localized
local classnames = locale == "deDE" and {
	["Warlock"] = "Hexenmeister",
	["Warrior"] = "Krieger",
	["Hunter"] = "Jäger",
	["Mage"] = "Magier",
	["Priest"] = "Priester",
	["Druid"] = "Druide",
	["Paladin"] = "Paladin",
	["Shaman"] = "Schamane",
	["Rogue"] = "Schurke",
} or locale == "frFR" and {
	["Warlock"] = "D\195\169moniste",
	["Warrior"] = "Guerrier",
	["Hunter"] = "Chasseur",
	["Mage"] = "Mage",
	["Priest"] = "Pr\195\170tre",
	["Druid"] = "Druide",
	["Paladin"] = "Paladin",
	["Shaman"] = "Chaman",
	["Rogue"] = "Voleur",
} or {
	["Warlock"] = "Warlock",
	["Warrior"] = "Warrior",
	["Hunter"] = "Hunter",
	["Mage"] = "Mage",
	["Priest"] = "Priest",
	["Druid"] = "Druid",
	["Paladin"] = "Paladin",
	["Shaman"] = "Shaman",
	["Rogue"] = "Rogue",
}

A reverse lookup table can also be created simply:

local reverseclassnames = {}
for i,v in pairs(classnames) do reverseclassnames[v] = i end