Help:Localisation
From Eugene Neighbors
{{#if: Help|{{#if:|Other languages:}} Template:H-langs:
{{#if: Help||}}|{{#if:|Other languages:}} Template:H-langs: {{#if: Help||}}}}
A collection of texts in various languages basically is a 2D array. They can be stored in templates in the following ways:
- for each text in each language there is a separate template, e.g.:
- ditto, but all translations are on the respective sites only, so the template name need not contain the language, e.g.:
- for each text (meaning) there is a template containing all translations, e.g.:
- for each language there is a template with all texts in that language (comparable to the php messsage files), e.g.
- there is one template containing the whole 2D array, e.g.:
One system for a multilingual template is that the template has an additional parameter "lan", and a text is produced depending on language; each line in {{#if:|{{#if:|[[{{#if:Help|Help:}}Localisation/examples#{{{2}}}|{{{3}}}]]|[[{{#if:Help|Help:}}Localisation/examples#{{{2}}}]]}}|{{#if:|[[{{#if:Help|Help:}}Localisation/examples|{{{3}}}]]|[[{{#if:Help|Help:}}Localisation/examples]]}}}} (talk, backlinks, edit) shows an example of a style for making template content dependent on the language parameter:
- {{MediaWiki:1movedto2/{{{lan}}}}}
- {{Lang name - de ({{{lan}}})}}
- {{Multilingual template demo/empty|lan={{{lan}}}}}
- {{N {{{lan}}}|de}}
- {{Ln|de {{{lan}}}}}
{{Help:Localisation/examples|lan=en}} gives:
- $1 moved to $2
- Template:Lang name - de (en)
- Template:Multilingual template demo/empty
- Template:N en
- Template:Ln
{{Help:Localisation/examples|lan=nl}} gives:
- $1 hernoemd naar $2
- Template:Lang name - de (nl)
- Template:Multilingual template demo/empty
- Template:N nl
- Template:Ln
For Template:HelpuMetaFarigxiMultlingva, Template:Tradukistoj, etc. it does not seem possible to select a language through a parameter; instead CSS or JS is used.
Contents |
[edit] Template name
When copying a template to another site a translated name can be used. In the case of multilingualism on one site, in the simple case where only the template names are multilingual, the content can be put under one name, while under the translated names there are only redirects.
If the content is also localised, each template can call a common template, but each time with a different value of parameter lan. E.g. Template:Links-core calls Template:Links-core with lan=en, and Template:Links-core calls the same template with lan=nl.
If the template has e.g. a complicated logical structure, it is convenient if that logic is contained in a common template, to avoid duplication of effort.
[edit] Template content
As seen above there are various ways to make texts dependent on the value of parameter lan. If the template calls another template, and for that template the name, parameter names, or parameter values have to be localised, then the outer template has to take care of these localisations too. If the localisation of the inner template has been carried out such it can be called with international names too (see also below) then localisation of various templates can be carried out more independently of each other.
Examples of language-dependent "texts" are also Template:Links-core and Template:Links-core. See also formatnum:, dependent on the format specified for the site, not on a template parameter "lan".
Note however that ParserFunctions #expr and #ifexpr only recognize a decimal point, and do not recognize any thousands separator.
[edit] Template parameter names
The localised templates can each use the localised name of a parameter. It calls the common template and gives an international parameter, e.g. "text", the value of the local parameter, e.g. "tekst". Two methods are:
- Parameter "text" is always defined; the value is the text "undefined" if parameter "tekst" is undefined:
- text={{{tekst|undefined}}}
- the state of being undefined is preserved, if parameter "tekst" is undefined then parameter "text" is left undefined too:
- {{#ifeq:{{{tekst|+}}}|{{{tekst|-}}}|text={{{tekst}}}}}
Correspondingly, if both parameter "tekst" and parameter "text" is allowed, and where if both are defined "tekst" prevails:
- text={{{tekst|{{{text|undefined}}}}}}
- Two methods ensuring that if neither parameter is defined parameter "text" is left undefined:
- {{#ifeq:{{{tekst|{{{text|+}}}}}}|{{{tekst|{{{text|-}}}}}}|text={{{tekst|{{{text}}}}}}}}
- {{#ifeq:{{{text|+}}}|{{{text|-}}}|text={{{text}}}}}|{{#ifeq:{{{tekst|+}}}|{{{tekst|-}}}|text={{{tekst}}}}}
Note that in the last method the dominating parameter is processed last, to override a possible value of "text".
[edit] Template parameter values
If a parameter value is not just passed through as text to be displayed, etc., but used in a condition, the possible parameter values can also be localised. We can either just allow the local versions of the values (the test value which a parameter value is compared is localised like ordinary text), or also allow the international version. In the latter case we can use something like {{#ifexpr:{{#ifeq:{{{font}}}|bold|1|0}}or{{#ifeq:{{{font}}}|vet|1|0}}|'''{{{text}}}'''|{{{text}}}}} ("vet" is Dutch for "bold").
[edit] See also
- Help:System message
- MediaWiki localisation
- {{#if:|{{#if:|[[mw:Manual:$wgLanguageCode#{{{2}}}|{{{3}}}]]|[[mw:Manual:$wgLanguageCode#{{{2}}}]]}}|{{#if:|{{{3}}}|mw:Manual:$wgLanguageCode}}}}
- Template:Links-core
- Template:Links-core
- {{#if:Generic namespace names|{{#if:|{{{3}}}|Help:Namespace#Generic namespace names}}|{{#if:|{{{3}}}|Help:Namespace}}}}
- bugzilla:8063 - JavaScript table sort does not observe local language with respect to digit groups, decimals and date formats
{{#if: Help|{{#if: Help|Template:Ph:Localisation}}
[edit] Links to other help pages
- Help contents (all help pages)
- Meta | Wikinews | Wikipedia | Wikiquote | Wiktionary | commons: | mw: | b: | s:
- Versions of this help page (for other languages see below)
- Meta | Wikinews | {{#if:|{{#if:Wikipedia|Wikipedia|w:Help:Localisation#}}|{{#if:Wikipedia|Wikipedia|w:Help:Localisation}}}} | Wikiquote | Wiktionary
- Links to this page from Meta (int) Meta (ext) Wikipedia MediaWiki
- Reading
- Go | Search | Stop words | URL | Namespace | Page name | Section
- Backlinks | Link | Piped link | Interwiki link | Redirect | Category | Image page
- Logging in and preferences
- Logging in | Preferences | User style
- Editing
- Advanced editing | Editing FAQ | Editing toolbar | Export | Import
- Editing tips and tricks | Editing shortcuts
- Tracking changes
- Recent changes (enhanced) | Related changes | Watching pages | Diff
- Page history | Edit summary | User contributions | Minor edit | Patrolled edit
- Style & formatting
- Wikitext examples | Wikitext reference | Reference card
- HTML in wikitext | HTML elements
- List | Table | Sorting
- Special input and output
- Inputbox | Special characters | Displaying a formula | Images and other uploaded files | EasyTimeline
- Advanced functioning
- Template | Advanced templates | Parser function | ParserFunctions | Parameter default | Variable | Magic word | System message | Substitution
- Array | Calculation
- Page management
- Starting a new page | Renaming (moving) a page | Maintenance | Merging and moving pages | Protecting pages
- Resolving disputes | Deleting a page
- Special pages
- Talk page | Testing | Sandbox
- Lists of resources
- Lists of Categories | Copyrights | Infobox
- Redirect | Reference Desk | Shortcuts | Stub types
Other languages: Template:H-langs:Localisation |{{#if: Help|Template:Ph:Localisation}}
[edit] Links to other help pages
- Help contents (all help pages)
- Meta | Wikinews | Wikipedia | Wikiquote | Wiktionary | commons: | mw: | b: | s:
- Versions of this help page (for other languages see below)
- Meta | Wikinews | {{#if:|{{#if:Wikipedia|Wikipedia|w:Help:Localisation#}}|{{#if:Wikipedia|Wikipedia|w:Help:Localisation}}}} | Wikiquote | Wiktionary
- Links to this page from Meta (int) Meta (ext) Wikipedia MediaWiki
- Reading
- Go | Search | Stop words | URL | Namespace | Page name | Section
- Backlinks | Link | Piped link | Interwiki link | Redirect | Category | Image page
- Logging in and preferences
- Logging in | Preferences | User style
- Editing
- Advanced editing | Editing FAQ | Editing toolbar | Export | Import
- Editing tips and tricks | Editing shortcuts
- Tracking changes
- Recent changes (enhanced) | Related changes | Watching pages | Diff
- Page history | Edit summary | User contributions | Minor edit | Patrolled edit
- Style & formatting
- Wikitext examples | Wikitext reference | Reference card
- HTML in wikitext | HTML elements
- List | Table | Sorting
- Special input and output
- Inputbox | Special characters | Displaying a formula | Images and other uploaded files | EasyTimeline
- Advanced functioning
- Template | Advanced templates | Parser function | ParserFunctions | Parameter default | Variable | Magic word | System message | Substitution
- Array | Calculation
- Page management
- Starting a new page | Renaming (moving) a page | Maintenance | Merging and moving pages | Protecting pages
- Resolving disputes | Deleting a page
- Special pages
- Talk page | Testing | Sandbox
- Lists of resources
- Lists of Categories | Copyrights | Infobox
- Redirect | Reference Desk | Shortcuts | Stub types
Other languages: Template:H-langs:Localisation }}
