Added more configuration variables to the Babelfish script
This commit is contained in:
+33
-13
@@ -1,15 +1,20 @@
|
||||
#!/usr/local/bin/lua
|
||||
|
||||
local locale = {
|
||||
"deDE",
|
||||
"frFR",
|
||||
"esES",
|
||||
"esMX",
|
||||
"zhCN",
|
||||
"zhTW",
|
||||
"koKR",
|
||||
"ruRU"
|
||||
}
|
||||
-- CONFIG --
|
||||
|
||||
--[[
|
||||
The name of the AceLocale-3.0 Category, as being used in :NewLocale and :GetLocale
|
||||
]]
|
||||
local localeName = "Bartender4"
|
||||
|
||||
--[[
|
||||
Prefix to all files if this script is run from a subdir, for example
|
||||
]]
|
||||
local filePrefix = "../"
|
||||
|
||||
--[[
|
||||
List of all files to parse
|
||||
]]
|
||||
local files = {
|
||||
"ActionBar.lua",
|
||||
"ActionBars.lua",
|
||||
@@ -35,11 +40,26 @@ local files = {
|
||||
"Options/Options.lua",
|
||||
}
|
||||
|
||||
--[[
|
||||
The supported Languages
|
||||
]]
|
||||
local locale = {
|
||||
"deDE",
|
||||
"frFR",
|
||||
"esES",
|
||||
"esMX",
|
||||
"zhCN",
|
||||
"zhTW",
|
||||
"koKR",
|
||||
"ruRU"
|
||||
}
|
||||
-- CODE --
|
||||
|
||||
local strings = {}
|
||||
|
||||
-- extract data from specified lua files
|
||||
for idx,filename in pairs(files) do
|
||||
local file = io.open("../"..filename, "r")
|
||||
local file = io.open(string.format("%s%s", filePrefix or "", filename), "r")
|
||||
assert(file, "Could not open " .. filename)
|
||||
local text = file:read("*all")
|
||||
|
||||
@@ -77,7 +97,7 @@ end
|
||||
local file = io.open("enUS.lua", "w")
|
||||
assert(file, "Could not open enUS.lua for writing")
|
||||
file:write("-- Generated by Babelfish script, do not edit directly.\n")
|
||||
file:write("local L = LibStub(\"AceLocale-3.0\"):NewLocale(\"Bartender4\", \"enUS\", true)\n")
|
||||
file:write(string.format("local L = LibStub(\"AceLocale-3.0\"):NewLocale(\"%s\", \"enUS\", true)\n", localeName))
|
||||
file:write("\n\n")
|
||||
for idx, match in ipairs(work) do
|
||||
file:write(string.format("L[\"%s\"] = true\n", match))
|
||||
@@ -89,7 +109,7 @@ for idx, lang in ipairs(locale) do
|
||||
local file = io.open(lang .. ".lua", "w")
|
||||
assert(file, "Could not open ".. lang .. ".lua for writing")
|
||||
file:write("-- Please make sure to save the file as UTF-8, BUT WITHOUT THE UTF-8 BOM HEADER; ¶\n")
|
||||
file:write(string.format("local L = LibStub(\"AceLocale-3.0\"):NewLocale(\"Bartender4\", \"%s\")\n", lang))
|
||||
file:write(string.format("local L = LibStub(\"AceLocale-3.0\"):NewLocale(\"%s\", \"%s\")\n", localeName, lang))
|
||||
file:write("if not L then return end\n")
|
||||
file:write("\n")
|
||||
local L = localizedStrings[lang]
|
||||
|
||||
Reference in New Issue
Block a user