Wiki source code of Language Macro

Last modified by Simon Urli on 2026/02/02 15:30

Hide last authors
Ecaterina Moraru (Valica) 1.1 1 = Example =
Thomas Mortagne 25.1 2
Ecaterina Moraru (Valica) 1.1 3 == Code ==
Thomas Mortagne 25.1 4
Ecaterina Moraru (Valica) 1.1 5 {{code}}
6 {{language codes='de, fr, it, lv, nl, ru, sv, zh'/}}
7 {{/code}}
8
9 == Result ==
10
Thomas Mortagne 25.1 11 {{language codes="de, fr, it, lv, nl, ru, sv, zh"/}}
Ecaterina Moraru (Valica) 1.1 12
Thomas Mortagne 25.1 13 = Parameters =
14
Ecaterina Moraru (Valica) 1.1 15 |= Parameter name |= Description
16 | codes | indicates the code list for the language
17
18 Codes that can be used:
Thomas Mortagne 25.1 19 {{velocity}}|= Code |= Flag |= Language name
Ecaterina Moraru (Valica) 1.1 20 #foreach($attachment in $doc.attachmentList)
Simon Urli 49.1 21 #if ($attachment.filename.endsWith('.png'))
Ecaterina Moraru (Valica) 1.1 22 #set($locale = $attachment.filename.substring(0, $attachment.filename.indexOf('.')).replace('-', '_'))
23 | $locale | image:$attachment.filename | $!{languages.get($locale).get(0)}
Simon Urli 49.1 24 #end
Thomas Mortagne 25.1 25 #end{{/velocity}}
Ecaterina Moraru (Valica) 1.1 26
27 == References ==
Thomas Mortagne 25.1 28
Simon Urli 42.1 29 The locale code is based on [[<ISO 639-1 language code~>>>https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes]]_[[<COUNTRY UPPER CASE~>>>https://en.wikipedia.org/wiki/ISO_3166-1]]
Thomas Mortagne 26.1 30
Thomas Mortagne 29.1 31 The flag need to be attachmed and the filename needs to be <locale>.png (for example ##pt_BR.png##). All the flags currently attached comes from [[http://www.famfamfam.com/lab/icons/flags/]].
32
Simon Urli 42.1 33 {{info}}
34 Since famfamfam.com seems to be down now, the zip containing all flags coming from this website has been retrieved from internet archive and added as attachment here for future needs.
35 {{/info}}
36
Thomas Mortagne 29.1 37 The display name needs to be added in the ##XWiki.WikiMacroClass## object.

Get Connected