Ir al contenido

Módulo:I18n

De Wikipedia, la enciclopedia libre
Esta es la versión actual de esta página, editada a las 22:50 2 ene 2019 por Strakhov (discusión · contribs.). La dirección URL es un enlace permanente a esta versión.
(difs.) ← Revisión anterior · Ver revisión actual (difs.) · Revisión siguiente → (difs.)
Este módulo no tiene página de documentación[crear]
local p = {}

-- Credit to http://stackoverflow.com/a/1283608/2644759
-- cc-by-sa 3.0
local function tableMerge(t1, t2, overwrite)
	for k,v in pairs(t2) do
		if type(v) == "table" and type(t1[k]) == "table" then
			-- since type(t1[k]) == type(v) == "table", so t1[k] and v is true
			tableMerge(t1[k], v, overwrite) -- t2[k] == v
		else
			if overwrite or t1[k] == nil then t1[k] = v end
		end
	end
	return t1
end

function p.loadI18n(name, i18n_arg)
	local exist, res = pcall(require, name)
	if exist and next(res) ~= nil then
		if i18n_arg then
			tableMerge(i18n_arg, res.i18n, true)
		elseif type(i18n) == "table" then
			-- merge to global i18n
			tableMerge(i18n, res.i18n, true)
		end
	end
end

function p.loadI18nFrame(frame, i18n_arg)
	p.loadI18n(frame:getTitle().."/i18n", i18n_arg)
end

return p
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy