No edit summary Tag: 2017 source edit |
No edit summary Tag: 2017 source edit |
||
Line 24: | Line 24: | ||
* Template:Languages/styles.css | * Template:Languages/styles.css | ||
== | == How it works == | ||
For the language switcher to work, you need to create the language versions of a page as the | The template defines some variables to determine which languages you want to support: | ||
* It automatically determines the content language of your wiki installation. This variable is required and must not be deleted. | |||
* You need to define at least one language for the switcher to make sense. Each language variable is named as "l1", "l2",.... The value needs to be provided as the [https://de.wikipedia.org/wiki/Liste_der_ISO-639-1-Codes ISO 639-1 language code] for the language. | |||
<syntaxhighlight lang="text"> | |||
{{#vardefine:l4|es}} | |||
</syntaxhighlight> | |||
* After defining the variables, you need to add them to the actual switcher: | |||
<syntaxhighlight lang="text"> | |||
|{{#var:l4}}={{#var:switcher}} | |||
</syntaxhighlight> | |||
* In addition, you should add the language to the template description for the extension [[Referenz:TemplateData|TemplateData]]: | |||
<syntaxhighlight lang="text"> | |||
"{{#var:l4}}": "Cambiador de idioma" | |||
</syntaxhighlight> | |||
==Displaying the switcher on a page== | |||
For the language switcher to work, you need to create the language versions of a page as subpages of the actual content language, e.g. in an English wiki: | |||
* Vacation policy | * Vacation policy | ||
Line 31: | Line 47: | ||
* Vacation policy/fr | * Vacation policy/fr | ||
The template is added to each language version | The template is then added to each language version: | ||
# Add the template ''Languages'' from the [[Manual:Extension/VisualEditor|VisualEditor]] insert-dialog. | # Add the template ''Languages'' from the [[Manual:Extension/VisualEditor|VisualEditor]] insert-dialog. | ||
# Provide a display title if the page is a subpage. For example for the Vacation policy/de, enter "Urlaubsregelung":[[File:HW-languageswitcher-templatedata.png|alt=Setting a display title|center|thumb|400x400px|Setting a display title]] | # Provide a display title if the page is a subpage. For example for the Vacation policy/de, enter "Urlaubsregelung":[[File:HW-languageswitcher-templatedata.png|alt=Setting a display title|center|thumb|400x400px|Setting a display title]] | ||
__NOTOC__ | __NOTOC__ |
Revision as of 11:39, 23 March 2022
This template creates a language switcher that supports English, German and French language pages. It can be inserted into a wiki page via the VisualEditor Insert > Template menu.
Importing the template
(The download file here only works in a wiki that is set to the content language English. For downloading the file for a wiki with content language set to German, go to the German Helpdesk.)
The import file is included in the archive file HW-LanguageSwitcher.zip. Unpack the zip file first.
On the page Special:Import follow these steps:
- Select file and choose HW-LanguageSwitcher.xml.
- Enter an Interwiki prefix. Since this field is required, simply add hw (for hallowelt).
- Keep the selection Import to default locations.
- Click Upload file... .
The template is now available in your wiki.
Pages included in the import
The xml import creates the following files in your wiki:
- Template:Languages
- Template:Languages/styles.css
How it works
The template defines some variables to determine which languages you want to support:
- It automatically determines the content language of your wiki installation. This variable is required and must not be deleted.
- You need to define at least one language for the switcher to make sense. Each language variable is named as "l1", "l2",.... The value needs to be provided as the ISO 639-1 language code for the language.
{{#vardefine:l4|es}}
- After defining the variables, you need to add them to the actual switcher:
|{{#var:l4}}={{#var:switcher}}
- In addition, you should add the language to the template description for the extension TemplateData:
"{{#var:l4}}": "Cambiador de idioma"
Displaying the switcher on a page
For the language switcher to work, you need to create the language versions of a page as subpages of the actual content language, e.g. in an English wiki:
- Vacation policy
- Vacation policy/de
- Vacation policy/fr
The template is then added to each language version:
- Add the template Languages from the VisualEditor insert-dialog.
- Provide a display title if the page is a subpage. For example for the Vacation policy/de, enter "Urlaubsregelung":