Module:Linguistic
From Neodyland Wiki
More actions
This documentation is transcluded from Module:Linguistic/doc.
-- some simple internationalization that can be called by other modules
local p = {}
local vowels = 'aeiouyąăẵằẳặȃắâẫấầẩậãäǟāáàȁǎảẚåǻḁạǡæǣǽĕȇêễếềểệḙẽḛëēḕéḗèȅěẻẹęȩḝǝĭȋîĩḭïḯīíìȉǐỉịįıŏȏôỗốồổộõṏṍöōṑóṓòȍǒỏọǫǭơỡớờởợøǿŭȗûṷũṻṹṵüǖǘǜǚṳūúùȕǔủůụųưữứừửựŷỹÿȳýỳỷẙỵ'
function isin(str, pattern)
if mw.ustring.find(str, pattern, 1, true ) then
return true
end
end
function langisin(str, lang)
return isin(str, lang .. ',') -- comma is necessary to avoid false positives like zh in zh-hans
end
function p.vowelfirst (str)
return isin(vowels, str[1])
end
function p.wordsep(lang) -- default separator between words
-- language with no separator
if langisin('zh, ja, zh-hans, zh-hant, zh-sg, zh-cn, sh-tw', lang) then
return ''
end
-- default: white space
return ' '
end
function p.noungroup(noun, adj, lang)
if not noun then
return nil end
if not adj
then return noun
end
-- adjective before the noun
if langisin('de, de-at, de-ch, en, en-ca, en-gb, zh ', lang) then
return adj .. p.wordsep(lang) .. noun
-- adjective after the noun
elseif langisin('fr, fr-ca, it') then
return noun .. p.wordsep(lang) .. adj
else
return noun ' (' .. adj .. ')'
end
end
return p