jbe/bsw@0: function locale._get_translation_table() jbe/bsw@0: local language_code = locale.get("lang") jbe/bsw@0: if language_code then jbe/bsw@0: if type(language_code) ~= "string" then jbe/bsw@0: error('locale.get("lang") does not return a string.') jbe/bsw@0: end jbe/bsw@0: local translation_table = locale._translation_tables[language_code] jbe/bsw@0: if translation_table then jbe/bsw@0: return translation_table jbe/bsw@0: end jbe@209: local filename = encode.file_path(WEBMCP_BASE_PATH, "locale", "translations." .. language_code .. ".lua") jbe@309: local func, load_errmsg = loadcached(filename) jbe@309: if not func then jbe@314: error('Could not load translation file: ' .. load_errmsg) jbe@64: end jbe/bsw@0: translation_table = func() jbe/bsw@0: if type(translation_table) ~= "table" then jbe/bsw@0: error("Translation file did not return a table.") jbe/bsw@0: end jbe/bsw@0: locale._translation_tables[language_code] = translation_table jbe/bsw@0: return translation_table jbe/bsw@0: else jbe/bsw@0: return locale._empty_translation_table jbe/bsw@0: end jbe/bsw@0: end