From 3238740e7dca9443bbf6f6f7f059644a936cf9ff Mon Sep 17 00:00:00 2001 From: Oreolek Date: Mon, 17 Aug 2015 04:32:37 +0700 Subject: [PATCH] folder for translations --- translate.lua | 9 +++++---- en.mo => translations/en.mo | Bin en.po => translations/en.po | 0 3 files changed, 5 insertions(+), 4 deletions(-) rename en.mo => translations/en.mo (100%) rename en.po => translations/en.po (100%) diff --git a/translate.lua b/translate.lua index 9eaae2c..7f7a77d 100644 --- a/translate.lua +++ b/translate.lua @@ -60,9 +60,7 @@ function load_mo_file(mo_file) local tl,to=peek_long(T),peek_long(T+4) T=T+8 hash[sub(mo_data,oo+1,oo+ol)]=sub(mo_data,to+1,to+tl) end - return function(text) - return hash[text] - end + return hash end @@ -75,7 +73,10 @@ if LANG == translate.source then return text; end; else - translate.strings = load_mo_file(LANG..'.mo'); + translate.strings = load_mo_file('translations/' .. LANG .. '.mo'); + if translate.strings == nil then + error("translation not found") + end _ = function(text) return translate.strings[text]; end diff --git a/en.mo b/translations/en.mo similarity index 100% rename from en.mo rename to translations/en.mo diff --git a/en.po b/translations/en.po similarity index 100% rename from en.po rename to translations/en.po