From 8664664151b2a0c99f277274f9fe08d1e8439b36 Mon Sep 17 00:00:00 2001 From: Hendrik Leppkes Date: Mon, 29 Sep 2008 10:49:46 +0200 Subject: [PATCH] Added more configuration variables to the Babelfish script --- locale/Babelfish.lua | 46 +++++++++++++++++++++++++++++++------------- 1 file changed, 33 insertions(+), 13 deletions(-) diff --git a/locale/Babelfish.lua b/locale/Babelfish.lua index c8b3218..1bfd67d 100644 --- a/locale/Babelfish.lua +++ b/locale/Babelfish.lua @@ -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]