-
Notifications
You must be signed in to change notification settings - Fork 62
Localization Substitution
Kyle Buller edited this page Oct 11, 2019
·
2 revisions
The CurseForge localization system allows people to contribute translations for your project easily without having to touch any code. You can enable localization support in your project settings under "General".
Once you have localization enabled, you can include your translated phrases
automatically when packaging by using the @localization@
keyword, which will
be replaced with your project's phrases.
For example @localization(locale="enUS", format="lua_additive_table")@
will
get replaced with some lines like L["Some key"] = "Some value"
.
-
locale
(required)- The locale for language you are exporting. One of: "enUS", "deDE", "esES", "esMX", "frFR", "itIT", "koKR", "ptBR", "ruRU", "zhCN", "zhTW".
-
format
(required)- "lua_additive_table" (default) - Output table entries. For example:
L["Some key"] = "Some value"
- "lua_table" - Output the entire table. For example:
{ ["Some key"] = "Some value", }
.
- "lua_additive_table" (default) - Output table entries. For example:
-
key
- Outputs the value of a single phrase. If used,
format
is ignored.
- Outputs the value of a single phrase. If used,
-
handle-unlocalized
- What happens to unlocalized phrases.- "english" (default) - Output the english value.
- "comment" - Output the english value and comment out the line.
- "blank" - Output "" as the value and comment out the line.
- "ignore" - No output.
-
escape-non-ascii
- false (default) - Strings will be UTF-8 encoded. For example: "Über".
- true - Non-ASCII characters will be escaped. For example: "\195\156ber".
-
table-name
- Name of the your table variable. This defaults to "L". Only used when format is "lua_additive_table".
-
same-key-is-true
- false (default) - Values are output as-is.
- true - Set value to true if it is the same as the key.
-
namespace
- Output a subset of phrases. Can be any namespace name, comma delimited.- "" (default) - Use the base namespace.
- "Monkey" - Use the namespace "Monkey".
- "Monkey/Banana" - Use the subnamespace "Banana" whose parent namespace is "Monkey".
-
handle-subnamespaces
- "none" (default) - Don't output subnamespaces.
- "concat" - Concatenate the namespace with the key with "/".
Here's an example using AceLocale-3.0:
local L = LibStub("AceLocale-3.0"):NewLocale("MyAddon", "enUS", true)
--@localization(locale="enUS", format="lua_additive_table", same-key-is-true=true, handle-subnamespaces="concat")@
Results in:
local L = LibStub("AceLocale-3.0"):NewLocale("MyAddon", "enUS", true)
L["Hello, World!"] = true
L["How are you today?"] = true
L["AwesomeModule/Eat some pie"] = "Eat some pie"
local L = LibStub("AceLocale-3.0"):NewLocale("MyAddon", "deDE")
if not L then return end
--@localization(locale="deDE", format="lua_additive_table", handle-subnamespaces="concat")@
Results in:
local L = LibStub("AceLocale-3.0"):NewLocale("MyAddon", "deDE")
if not L then return end
L["Hello, World!"] = "Hallo, Welt!"
-- L["How are you today?"] = "How are you today?"
L["AwesomeModule/Eat some pie"] = "Geh Kuchen essen"