Difference between revisions of "Module:Translated"
Jump to navigation
Jump to search
(avoid unnecessary newline) |
|||
Line 1: | Line 1: | ||
− | -- This module is created as a proposal to partially replace the existing Template:Translated | + | --[[ This module is created as a proposal to partially replace the existing Template:Translated |
+ | |||
+ | Note on zh-*: | ||
+ | Certain language conversion tools for conversion between zh-hant and zh-hans appears to be quite reliable. However: | ||
+ | * I am not sure whether the use of such tools makes sense for this particular wiki. | ||
+ | * I am not sure which particular tool should be used. Currently I only know OpenCC (used for the l10n branch of advtrains) and the conversion tool used for zh.wikipedia.org | ||
+ | * OpenCC does not provide a Lua API, and I don't think Scribunto allows loading C/C++ wrapper libraries. Therefore, it would involve a re-implementation. | ||
+ | * I do not know whether the tool used on zh.wikipedia.org can be used on this wiki or has a Lua API. | ||
+ | Further discussions can take place on the talk page. | ||
+ | - ywang | ||
+ | ]] | ||
-- List of languages to check localized pages for | -- List of languages to check localized pages for |
Revision as of 20:31, 17 July 2021
--[[ This module is created as a proposal to partially replace the existing Template:Translated
Note on zh-*:
Certain language conversion tools for conversion between zh-hant and zh-hans appears to be quite reliable. However:
* I am not sure whether the use of such tools makes sense for this particular wiki.
* I am not sure which particular tool should be used. Currently I only know OpenCC (used for the l10n branch of advtrains) and the conversion tool used for zh.wikipedia.org
* OpenCC does not provide a Lua API, and I don't think Scribunto allows loading C/C++ wrapper libraries. Therefore, it would involve a re-implementation.
* I do not know whether the tool used on zh.wikipedia.org can be used on this wiki or has a Lua API.
Further discussions can take place on the talk page.
- ywang
]]
-- List of languages to check localized pages for
local langlist = {
de = "🇩🇪",
ru = "🇷🇺",
fr = "🇫🇷",
es = "🇪🇸",
-- I did not add the flags for zh-hans and zh-hant mainly for political reasons
["zh-hans"] = "",
["zh-hant"] = "",
}
local function main(frame)
-- It is common for modules to have wrapper functions. In this case it can be (for example) {{#invoke:Translated|main|{{{pagename|{{NAMESPACE}}:{{BASEPAGENAME}}}}}}}, which should work in most cases.
local pagename = frame.args.pagename or error("No page name supplied")
local basestr = string.format([=[
{| class="wikitable"
|-
| '''Other languagues''' ||
[[%s|🇬🇧 English]]]=], pagename)
local stringlist = {basestr}
for lang, icon in pairs(langlist) do
local title = mw.title.new(pagename .. "/" .. lang)
if title.exists then -- WARNING: EXPENSIVE OPERATION
stringlist[#stringlist+1] = string.format(" - [[%s/%s|%s %s]]", pagename, lang, icon, mw.language.fetchLanguageName(lang))
end
end
stringlist[#stringlist+1] = "\n|}"
return table.concat(stringlist)
end
return {main = main}