Jump to content

Module:Nihongo and Module:Nihongo/sandbox: Difference between pages

(Difference between pages)
Page 1
Page 2
Content deleted Content added
fix misleading code comment
 
add top-level local constant `japanese_lang_code`
 
Line 1: Line 1:
require('strict');
require('strict');

local japanese_lang_code = 'ja'


--[[--------------------------< E R R O R _ M E S S A G E S >--------------------------------------------------
--[[--------------------------< E R R O R _ M E S S A G E S >--------------------------------------------------
Line 25: Line 27:
local cfg = {
local cfg = {
['nihongo'] = {
['nihongo'] = {
tag = 'ja',
system = 'hepburn',
system = 'hepburn',
system_link = '[[Hepburn romanization|Hepburn]]',
system_link = '[[Hepburn romanization|Hepburn]]',
Line 32: Line 33:
},
},
['nihongo3'] = {
['nihongo3'] = {
tag = 'ja',
system = 'hepburn',
system = 'hepburn',
err_msg = err_msg.nihongo,
err_msg = err_msg.nihongo,
Line 38: Line 38:
},
},
['nihongo krt'] = {
['nihongo krt'] = {
tag = 'ja',
system = 'hepburn',
system = 'hepburn',
err_msg = err_msg.nihongo,
err_msg = err_msg.nihongo,
Line 44: Line 43:
},
},
['nihongo foot'] = {
['nihongo foot'] = {
tag = 'ja',
system = 'hepburn',
system = 'hepburn',
system_link = '[[Hepburn romanization|Hepburn]]',
system_link = '[[Hepburn romanization|Hepburn]]',
Line 173: Line 171:
end
end
if native then
if native then
native = lead and lang_module._langx ({['code']=cfg[template].tag, ['text']=native, ['template']=template}) or
native = lead and lang_module._langx ({['code']=japanese_lang_code, ['text']=native, ['template']=template}) or
lang_module._lang ({cfg[template].tag, native, ['template']=template}); -- add ja script with/without language prefix
lang_module._lang ({japanese_lang_code, native, ['template']=template}); -- add ja script with/without language prefix
end
end
if romanized then
if romanized then
romanized = (lead and english and (cfg[template].system_link .. ': ') or '') .. lang_module._xlit ({'ja', cfg[template].system, romanized, ['template']=template}) or nil;
romanized = (lead and english and (cfg[template].system_link .. ': ') or '') .. lang_module._xlit ({japanese_lang_code, cfg[template].system, romanized, ['template']=template}) or nil;
end
end


Line 226: Line 224:
return error_message (template);
return error_message (template);
end
end
native = native and lang_module._lang ({cfg[template].tag, native, ['template']=template}) or nil;
native = native and lang_module._lang ({japanese_lang_code, native, ['template']=template}) or nil;
romanized = romanized and lang_module._xlit ({cfg[template].tag, cfg[template].system, romanized, ['template']=template}) or nil;
romanized = romanized and lang_module._xlit ({japanese_lang_code, cfg[template].system, romanized, ['template']=template}) or nil;
local formatting = { -- <5p4n> and </5p4n>: place holders for font-weight style spans; akin to stripmarkers, replaced before function returns
local formatting = { -- <5p4n> and </5p4n>: place holders for font-weight style spans; akin to stripmarkers, replaced before function returns
Line 272: Line 270:
return error_message (template);
return error_message (template);
end
end
native = native and lang_module._lang ({cfg[template].tag, native, ['template']=template}) or nil;
native = native and lang_module._lang ({japanese_lang_code, native, ['template']=template}) or nil;
romanized = romanized and lang_module._xlit ({cfg[template].tag, cfg[template].system, romanized, ['template']=template}) or nil;
romanized = romanized and lang_module._xlit ({japanese_lang_code, cfg[template].system, romanized, ['template']=template}) or nil;
local formatting = { -- <5p4n> and </5p4n>: place holders for font-weight style spans; akin to stripmarkers, replaced before function returns
local formatting = { -- <5p4n> and </5p4n>: place holders for font-weight style spans; akin to stripmarkers, replaced before function returns
Line 325: Line 323:
end
end
if native then
if native then
native = lead and lang_module._langx ({['code']=cfg[template].tag, ['text']=native, ['template']=template}) or
native = lead and lang_module._langx ({['code']=japanese_lang_code, ['text']=native, ['template']=template}) or
lang_module._lang ({cfg[template].tag, native, ['template']=template}); -- add ja script with/without language prefix
lang_module._lang ({japanese_lang_code, native, ['template']=template}); -- add ja script with/without language prefix
end
end
if romanized then
if romanized then
romanized = (lead and (cfg[template].system_link .. ': ') or '') .. lang_module._xlit ({'ja', cfg[template].system, romanized, ['template']=template}) or nil;
romanized = (lead and (cfg[template].system_link .. ': ') or '') .. lang_module._xlit ({japanese_lang_code, cfg[template].system, romanized, ['template']=template}) or nil;
end
end