Модуль:переклад
Зовнішній вигляд
Документацію для цього модуля можна створити у Модуль:переклад/документація
p = {}
--creating different "tables" because of: kk.arab, kk.lat etc
----(they can be put in a module which will return their interpretation
----lang['en'].interpratation = '[[англійська]]'
----lang['fr'].interpratation = '[[французька]]'
----lang['kk.arab'].interpratation = '[[казахська]] (араб.): '
----etc. etc.)
local chunk1 = { 'ab', 'af', 'ain', 'als', 'am', 'an', 'ang', 'ar', 'ast', 'av', 'ay', 'az',
'ba', 'bar', 'bat-smg', 'be', 'bg', 'bn', 'bpy', 'br', 'bs',
'ca', 'co', 'cop', 'crh', 'csb', 'cy',
'da', 'dv', 'dz',
'el', 'en', 'eo', 'es', 'et', 'eu',
'ga', 'gan', 'gd', 'gl', 'glk', 'gn', 'got', 'grc', 'gu',
'haw', 'he', 'hi', 'hsb', 'ht', 'hy',
'ia', 'id', 'ido', 'ie', 'ik', 'ilo', 'inh', 'io', 'is', 'it', 'jbo',
'ka', 'kk'}
local chunk2 = { 'kn', 'ko', 'kom', 'krl', 'krl', 'ku', 'kw', 'ky',
'la', 'lad', 'lb', 'lez', 'li', 'lmo', 'ln', 'lt', 'lv',
'mg', 'mk', 'myv', 'nah', 'qu', 'qya',
'rmr', 'sq', 'vep', 'vi', 'vls', 'vo', 'vot', 'vro',
'wa', 'wo', 'xh', 'yi', 'yo', 'ze', 'zh', 'zh-cn', 'zh-nan', 'zh-tw', 'zu'
}
--TODO:fill rest of languages
local chunk3 = {}
function p.main(frame)
local lemmaargs = frame:getParent().args
local translations = {}
local teststr = ''
local dummytest = ''
local traslcounter = 1
local concattranslations = ''
local center = 0
--create lines of translations if they exist
for itemcounter = 1, #chunk1 do
dummytest = lemmaargs[chunk1[itemcounter]] or ''
if dummytest ~= '' then
translations[traslcounter] = '* ' .. frame:expandTemplate{ title = chunk1[itemcounter], args = { } } .. ': ' .. dummytest .. '\n'
traslcounter = traslcounter +1
end
end
dummytest = lemmaargs['kk.arab'] or ''
if dummytest ~= '' then
translations[traslcounter] = '* ' .. frame:expandTemplate{ title = 'kk', args = { } } .. ' (араб.): ' .. dummytest .. '\n'
traslcounter = traslcounter +1
end
dummytest = lemmaargs['kk.cyr'] or ''
if dummytest ~= '' then
translations[traslcounter] = '* ' .. frame:expandTemplate{ title = 'kk', args = { } } .. ' (кир.): ' .. dummytest .. '\n'
traslcounter = traslcounter +1
end
dummytest = lemmaargs['kk.lat'] or ''
if dummytest ~= '' then
translations[traslcounter] = '* ' .. frame:expandTemplate{ title = 'kk', args = { } } .. ' (лат.): ' .. dummytest .. '\n'
traslcounter = traslcounter +1
end
--TODO: add check for rest of lang codes
--for _,v in pairs(chunk2) do
----etc. etc.
--start creating the output
----navhead
local output = [=[<div class="NavFrame">
<div class="NavHead" style="text-align: left; padding-left: 0.8em;">]=]
--if we have a title for the translations
--TODO: PROBLEM if title includes a "="
--it is interpeted as a named parameter and not parameter 1
if lemmaargs[1] then
output = output .. "'''" .. lemmaargs[1] .. [=['''</div>
<div class="NavContent">
]=]
end
----table top
output = output .. [=[{| border="0" width="100%" style="clear:both;"
|-
| bgcolor="#eef9ff" valign="top" width="48%" |
{|
]=]
--concatenate translations
--if there are any translations
if #translations > 0 then
output = output .. translations[1]
--if more than 1
if #translations > 1 then
--calculate middle
center = math.ceil((traslcounter-1)/2)
for xcounter = 2,center do
output = output .. translations[xcounter]
end
end
end
----table middle
output = output .. [=[
|}
| width="1%" |
| bgcolor="#eef9ff" valign="top" align="left" width="48%" |
{|
]=]
--if more than 1
if #translations > 1 then
for xcounter = center+1, #translations do
output = output .. translations[xcounter]
end
end
----table bottom
output = output .. [=[
|}
|}</div>
</div>
]=]
return output
end
return p