Module:Lang: Difference between revisions

Jump to navigation Jump to search
Sur (talk | contribs)
m fixed fallback_str='en' localizing to current lang instead of en
Sur (talk | contribs)
m 'dictionary' for fallback_str can now fallback to dictionary translation
Line 2: Line 2:
local util_module = require("Module:Utilities")
local util_module = require("Module:Utilities")
local lang_codes_set = mw.loadJsonData("Data:LangCodes.json")
local lang_codes_set = mw.loadJsonData("Data:LangCodes.json")
local dictionary_module = require("Module:Dictionary")


-- Overrides applied to searches by key. Designed to handle edge cases where
-- Overrides applied to searches by key. Designed to handle edge cases where
Line 62: Line 63:
if (fallback_str == 'en') then
if (fallback_str == 'en') then
fallback = p.get_string(key, 'en', key .. fallback_tooltip, remove_var_index, upper_lower)
fallback = p.get_string(key, 'en', key .. fallback_tooltip, remove_var_index, upper_lower)
elseif fallback_str == 'dictionary' then
fallback = dictionary_module.translate(key, lang_code_override)
elseif fallback_str ~= nil then
elseif fallback_str ~= nil then
fallback = fallback_str
fallback = fallback_str