Module:Linguistic: Difference between revisions
From Neodyland Wiki
More actions
ce |
m table may be written as variable or programmatically filled, ... also there was a little bug: << " or lang == 'ja' or 'zh-hans' " >> which would make it always true and thus returning no space for every lang |
||
| Line 11: | Line 11: | ||
function p.wordsep(lang) -- default separator between words | function p.wordsep(lang) -- default separator between words | ||
-- language with no separator | -- language with no separator | ||
if | if ({ zh=1, ja=1, ['zh-hans']=1, ['zh-hant']=1, ['zh-sg']=1, ['zh-cn']=1, ['zh-tw']=1})[lang] then | ||
return '' | return '' | ||
end | end | ||
Revision as of 11:10, 22 November 2013
This documentation is transcluded from Module:Linguistic/doc.
-- some simple internationalization that can be called by other modules
local p = {}
local vowels = 'aeiouyąăẵằẳặȃắâẫấầẩậãäǟāáàȁǎảẚåǻḁạǡæǣǽĕȇêễếềểệḙẽḛëēḕéḗèȅěẻẹęȩḝǝĭȋîĩḭïḯīíìȉǐỉịįıŏȏôỗốồổộõṏṍöōṑóṓòȍǒỏọǫǭơỡớờởợøǿŭȗûṷũṻṹṵüǖǘǜǚṳūúùȕǔủůụųưữứừửựŷỹÿȳýỳỷẙỵ'
function p.vowelfirst (str)
if mw.ustring.find(vowels, str[1], 1, true ) then
return true
end
end
function p.wordsep(lang) -- default separator between words
-- language with no separator
if ({ zh=1, ja=1, ['zh-hans']=1, ['zh-hant']=1, ['zh-sg']=1, ['zh-cn']=1, ['zh-tw']=1})[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 lang == en or lang == de then
return adj .. p.wordsep(lang) .. noun
-- adjective after the noun
elseif lang == 'fr' or lang == 'fr-ca' then
return noun .. p.wordsep(lang) .. adj
else
return noun ' (' .. adj .. ')'
end
end
return p