Template:Lang
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-protoasterisk 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:Langxcompanion 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)