This is an old revision of this page, as edited by Hohum(talk | contribs) at 23:04, 19 May 2024(←Created page with 'local p = {} local function split_with_comma(str) local fields = {} for field in str:gmatch('([^,]+)') do fields[#fields+1] = ltrim (field) end return fields end function ltrim(s) return s:match'^%s*(.*)' end function p.countrynames( frame ) -- local test = frame.args[1] .. ", " .. frame.args.property -- return test -- change comma list to array countryarray = split_with_comma( frame.args[1] ) -- put each array entry through Module:...'). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.Revision as of 23:04, 19 May 2024 by Hohum(talk | contribs)(←Created page with 'local p = {} local function split_with_comma(str) local fields = {} for field in str:gmatch('([^,]+)') do fields[#fields+1] = ltrim (field) end return fields end function ltrim(s) return s:match'^%s*(.*)' end function p.countrynames( frame ) -- local test = frame.args[1] .. ", " .. frame.args.property -- return test -- change comma list to array countryarray = split_with_comma( frame.args[1] ) -- put each array entry through Module:...')
This module is rated as beta, and is ready for widespread use. It is still new and should be used with some caution to ensure the results are as expected.
This module is subject to page protection. It is a highly visible module in use by a very large number of pages, or is substituted very frequently. Because vandalism or mistakes would affect many pages, and even trivial editing might cause substantial load on the servers, it is protected from editing.
This module depends on the following other modules:
localp={}localfunctionsplit_with_comma(str)localfields={}forfieldinstr:gmatch('([^,]+)')dofields[#fields+1]=ltrim(field)endreturnfieldsendfunctionltrim(s)returns:match'^%s*(.*)'endfunctionp.countrynames(frame)-- local test = frame.args[1] .. ", " .. frame.args.property-- return test-- change comma list to arraycountryarray=split_with_comma(frame.args[1])-- put each array entry through Module:ISO 3166. If the result is null, keep original entrylocalISO_3166=require('Module:ISO 3166')fori=1,#countryarraydoshortname=ISO_3166.name({countryarray[i]})ifshortname~=""thencountryarray[i]=shortnameendend-- change array back to comma stringcommastring=""fori=1,#countryarray-1docommastring=commastring..ltrim(countryarray[i])..", "endcommastring=commastring..ltrim(countryarray[#countryarray])returncommastringendreturnp