Template:Lang

Revision as of 19:51, 14 July 2026 by SGPolitico (talk | contribs) (Created page with "<includeonly>{{#if:{{{2|{{{text|}}}}}}|{{#switch:{{{italic|auto}}} | no = <span title="{{#switch:{{{1|{{{code|}}}}}}|zh|zh-Hans|zh-Hant|zh-CN|zh-TW|zh-SG|zh-HK=Chinese|ja=Japanese|ko=Korean|th=Thai|ar=Arabic|he=Hebrew|hi=Hindi|ta=Tamil|ru=Russian|ms=Malay|fr=French|de=German|es=Spanish|it=Italian|pt=Portuguese|la=Latin|#default={{{1|{{{code|}}}}}}}}-language text"><span lang="{{{1|{{{code|}}}}}}" style="font-style: normal;"{{#if:{{{rtl|}}}| dir="rtl"}}>{{{2|{{{text|}}}}}...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Usage

A Lua-free reimplementation of Wikipedia's {{lang}}, built for Politicalsg because the wiki cannot run Scribunto/Lua (proc_open is blocked; any #invoke errors). This version uses only and .

{{lang|language code|text}}

Deviations from the Wikipedia original — read before assuming parity:

  • No Lua means no full IETF-tag validation, no ISO 639 database lookup, and no automatic per-language subcategorisation. Everything below is hand-coded.
  • Italics default is decided by a fixed list of language codes, not real script detection. CJK, Arabic, Hebrew, Devanagari, Cyrillic-family and a few other non-Latin codes render upright by default; everything else (French, German, Malay, Spanish, etc.) renders in italics by default. Override with |italic=yes, |italic=no, or |italic=unset.
  • The title="...-language text" attribute only resolves a language name for the codes in the switch list above (mainly the ones actually in use on this wiki: Chinese variants, Japanese, Korean, Thai, Arabic, Hebrew, Hindi, Tamil, Russian, Malay, French, German, Spanish, Italian, Portuguese, Latin). Anything else falls back to showing the raw code, e.g. title="cy-language text" instead of "Welsh-language text". Add more codes to the switch list as the wiki needs them.
  • Categorisation is a single flat , not per-language subcategories (Wikipedia's Module:Lang generates ~150 of those; not worth building without Lua). Suppress with |nocat=yes.
  • No support for script/region/variant subtags beyond what's hard-coded above (no zh-Latn-pinyin-style transliteration handling, no -x-proto asterisk prefixing). If a page needs that, extend the switch list rather than trying to genericise it — this wiki's actual use cases are narrow (mostly Chinese-language quotes in event pages).
  • No Template:Langx companion template built yet. If a page needs the "Chinese: 讲华语" prefixed form, that would be a separate template built the same way (switch-based name lookup + this same span logic).

Examples

{{lang|zh-Hans|讲华语运动}}

→ renders upright, title="Chinese-language text"

{{lang|fr|Je suis française.}}

→ renders in italics, title="French-language text"

{{lang|zh-Hans|讲华语运动|nocat=yes}}

→ same, but does not add the category (use inside wikilinks/citation titles, same as upstream)