Update missing translations table

This commit is contained in:
Eduardo Bart
2012-07-30 20:52:06 -03:00
parent 3db0ae06a7
commit 1de9faa93e
9 changed files with 1641 additions and 293 deletions

View File

@@ -1,8 +1,7 @@
-- TIP: to find all possible translations in the modules directory use the following command
-- find \( -name "*.lua" -o -name "*.otui" \) -exec grep -oE "tr\\('(\\\\'|[^'])*'" {} \; -exec grep -oE "tr\\(\"(\\\\\"|[^\"])*" {} \; | sort | uniq | sed "s/^tr(.\(.*\).$/[\"\1\"] = nil,/"
Locales = { }
dofile 'neededtranslations.lua'
-- private variables
local defaultLocaleName = 'en'
local installedLocales
@@ -75,11 +74,39 @@ function Locales.terminate()
disconnect(g_game, { onGameStart = onGameStart })
end
function generateNewTranslationTable(localename)
local locale = installedLocales[localename]
for _i,k in pairs(Locales.neededTranslations) do
local trans = locale.translation[k]
k = k:gsub('\n','\\n')
k = k:gsub('\t','\\t')
k = k:gsub('\"','\\\"')
if trans then
trans = trans:gsub('\n','\\n')
trans = trans:gsub('\t','\\t')
trans = trans:gsub('\"','\\\"')
end
if not trans then
print(' ["' .. k .. '"]' .. ' = false,')
else
print(' ["' .. k .. '"]' .. ' = "' .. trans .. '",')
end
end
end
function Locales.installLocale(locale)
if not locale or not locale.name then
error('Unable to install locale.')
end
if locale.name ~= defaultLocaleName then
for _i,k in pairs(Locales.neededTranslations) do
if locale.translation[k] == nil then
pwarning('Translation for locale \'' .. locale.name .. '\' not found: \"' .. k.. '\"')
end
end
end
local installedLocale = installedLocales[locale.name]
if installedLocale then
for word,translation in pairs(locale.translation) do