Module:Sandbox/Erutuon: Difference between revisions

Content deleted Content added
add chars_in_scripts_in_block function
experiment with searching for language codes in Template:lang and lang-xx templates in article text
Line 165:
return script_char_set_map
end
end
 
function p.search_for_language_codes(frame)
local page_name = "English language"
local content = mw.title.new(page_name):getContent()
local language_codes = {}
for lang_template in content:gmatch '{{lang[^}]+' do
local template_name = lang_template:match('{{([^|}]+)')
local language_code
if template_name == 'lang' then
language_code = lang_template:match '{{lang|([^|}]+)'
elseif template_name:find '^lang-' then
language_code = lang_template:match '{{lang-([^|}]+)'
end
if language_code then
language_codes[language_code] = true
end
end
return table.concat(m_table.keysToList(language_codes), ', ')
end