Module:Engvar/detect
Appearance
From Wikipedia, the free encyclopedia
You might want to create a documentation page for this Scribunto module.
Editors can experiment in this module's sandbox (edit | diff) and testcases (create) pages.
Add categories to the /doc subpage. Subpages of this module.
Editors can experiment in this module's sandbox (edit | diff) and testcases (create) pages.
Add categories to the /doc subpage. Subpages of this module.
localengvar_template_patterns={ --British, EngvarB, and American are listed first because they are the most commonly used ['{{ *[Uu]se [Bb]i?ri?tish [Ee]nglish *[|}]']='en-GB', ['{{ *[Ee][Nn]gvar ?-? ?[Bb] *[|}]']='en-GB', ['{{ *[Uu]se [Aa]merican [Ee]nglish *[|}]']='en-US', -- Remaining countries in alphabetical order ['{{ *[Uu]se [Aa]ustralian [Ee]nglish *[|}]']='en-AU', ['{{ *[Uu]se [Cc]anadian [Ee]nglish *[|}]']='en-CA', ['{{ *[Uu]se [Hh]iberno ?-? ?[Ee]nglish *[|}]']='en-EI', ['{{ *[Uu]se [Hh]ong [Kkong] [Ee]nglish *[|}]']='en-HK', ['{{ *[Uu]se [Ii]ndian [Ee]nglish *[|}]']='en-IN', ['{{ *[Uu]se IUPAC [Ee]nglish *[|}]']='en-IUPAC',-- redirects to {{Use Oxford Spelling}}, but en-IUPAC is used here because it's supported by {{Engvar}} ['{{ *[Uu]se [Jj]amacan [Ee]nglish *[|}]']='en-JM', ['{{ *[Uu]se [Nn]ew [Zz]ealand [Ee]nglish *[|}]']='en-NZ', ['{{ *[Uu]se [Nn]igerian [Ee]nglish *[|}]']='en-NG', ['{{ *[Uu]se [Oo]xford [Ss]pelling *[|}]']='en-OED', ['{{ *[Uu]se [Pp]akistani? [Ee]nglish *[|}]']='en-PK', ['{{ *[Uu]se [Pp]hilippine [Ee]nglish *[|}]']='en-PH', ['{{ *[Uu]se [Ss]cottish [Ee]nglish *[|}]']='en-SCO',-- redirects to {{Use British English}}, but en-SCO is used here because it's supported by {{Engvar}} ['{{ *[Uu]se [Ss]ingapore [Ee]nglish *[|}]']='en-SG', ['{{ *[Uu]se [Ss]outh [Aa]frican? [Ee]nglish *[|}]']='en-ZA', ['{{ *[Uu]se [Tt]rinidad [Aa]nd [Tt]obago [Ee]nglish *[|}]']='en-TT', -- Redirects to the above templates ['{{ *[Ee][Bb] *[|}]']='en-GB', ['{{ *[Ee]n-?[Gg][Bb] *[|}]']='en-GB', ['{{ *[Uu]se [Bb]ritish *[|}]']='en-GB', ['{{ *[Uu][Bb][Ee] *[|}]']='en-GB', ['{{ *[Uu]se [Bb][Rr][Ee] *[|}]']='en-GB', ['{{ *[Uu]se [Ww]elsh [Ee]nglish *[|}]']='en-GB', ['{{ *[Uu]se [Bb]ritish [Ee]nglish spelling *[|}]']='en-GB', ['{{ *[Uu][Kk]-?[Ee][Nn] *[|}]']='en-GB', ['{{ *[Uu]se [Ee]uropean [Ee]nglish *[|}]']='en-GB',-- redirects to {{EngvarB}} ['{{ *[Uu]se [Ii]nternational [Ee]nglish *[|}]']='en-GB',-- redirects to {{EngvarB}} ['{{ *[Ii]nternational [Ee]nglish *[|}]']='en-GB',-- redirects to {{EngvarB}} ['{{ *[Uu]se [Uu]%.?[Ss]%.? [Ee]nglish *[|}]']='en-US', ['{{ *[Uu]se [Uu]nited [Ss]tates [Ee]nglish *[|}]']='en-US', ['{{ *[Ee]ngvar[Aa] *[|}]']='en-US', ['{{ *[Ee]n-?[Uu][Ss] *[|}]']='en-US', ['{{ *[Uu][Ss]-?[Ee]n *[|}]']='en-US', ['{{ *[Ee]ngvar[Aa][Uu] *[|}]']='en-AU', ['{{ *[Ee]ngvar[Cc] *[|}]']='en-CA', ['{{ *[Ee]n-?[Cc][Aa]] *[|}]']='en-CA', ['{{ *[Uu]se [Hh]iberno ?-? ?[Ee]nglish [Ss]pelling *[|}]']='en-EI', ['{{ *[Uu]se [Ii]rish [Ee]nglish *[|}]']='en-EI', ['{{ *[Ee]n-?[Hh][Kk]] *[|}]']='en-HK', ['{{ *[Hh][Kk]-?[Ee]n *[|}]']='en-HK', ['{{ *[Uu]se [Bb]ritish %(?IUPAC%)? [Ee]nglish *[|}]']='en-IUPAC',-- redirects to {{Use Oxford Spelling}}, but en-IUPAC is used here because it's supported by {{Engvar}} ['{{ *[Ee]n-?[Nn][Zz]] *[|}]']='en-NZ', ['{{ *[Uu]se [Nn][Zz] [Ee]nglish *[|}]']='en-NZ', ['{{ *[Ee]ngvar[Oo]x? *[|}]']='en-OED', ['{{ *[Uu]se [Bb]ritish %(?[Oo]xford%)? [Ee]nglish *[|}]']='en-OED', ['{{ *[Uu]se [Oo]xford [Ee]nglish *[|}]']='en-OED', ['{{ *[Ee]n-[Gg][Bb]-oxendict *[|}]']='en-OED', ['{{ *[Uu]se [Bb]ritish [Ee]nglish %(?[Oo]xford%)? [Ss]pelling *[|}]']='en-OED', ['{{ *[Uu]se [Ff]ilipino [Ee]nglish *[|}]']='en-PH', ['{{ *[Uu]se [Ss]ingaporean [Ee]nglish *[|}]']='en-SG', ['{{ *[Uu][Zz][Aa][Ee] *[|}]']='en-ZA', ['{{ *[Uu]se [Tt]rinidadian [Ee]nglish *[|}]']='en-TT', }; localfunctionget_lang_var(pagename) localtitle_object=pagenameandmw.title.new(pagename)ormw.title.getCurrentTitle(); localcontent; if10~=title_object.namespaceand828~=title_object.namespacethen-- all namespaces except Template and Module content=title_object:getContent()or'';-- get the content of the article or ''; new pages edited w/ve do not have 'content' until saved; ve does not preview; phab:T221625 end if(notcontentorcontent=='')then returnnil; end forpattern,varinpairs(engvar_template_patterns)do-- loop through the patterns looking for {{Use American English}}, {{Use British English}}, etc., or any of their redirects ifcontent:find(pattern)then returnvar; end end returnnil; end return{detect=get_lang_var}