No edit summary |
No edit summary |
||
Line 20: | Line 20: | ||
The following information gives you some suggestions for how to organise a wiki around its multilingual content based on these aspects. It does not consider using the MediaWiki extension [[mediawikiwiki:Extension:Translate|Translate]] which is often installed in multlingual wikis to faciliate a section-by-section translation of wiki pages. If most of your wiki content needs consistently accurate translations, this extension can be | The following information gives you some suggestions for how to organise a wiki around its multilingual content based on these aspects. It does not consider using the MediaWiki extension [[mediawikiwiki:Extension:Translate|Translate]] which is often installed in multlingual wikis to faciliate a section-by-section translation of wiki pages. If most of your wiki content needs consistently accurate translations, this extension can be valuable. | ||
== Importing the language switcher == | == Importing the language switcher == | ||
Line 30: | Line 30: | ||
== Creating wiki pages with translated subpages == | == Creating wiki pages with translated subpages == | ||
Let's take a page called ''Vacation policy'' and create a German language version as a subpage. After saving the page ''Vacation policy/d''e and providing the content translation, we have the German translation that we wanted. As you can see in the screenshots below, the page content is always shown in the context of the user language preferences of each user. This means that the user interface elements do not necessarily correspond to the translated language. But since the user decided on this language preference, it does not negatively | Let's take a page called ''Vacation policy'' and create a German language version as a subpage. After saving the page ''Vacation policy/d''e and providing the content translation, we have the German translation that we wanted. As you can see in the screenshots below, the page content is always shown in the context of the user language preferences of each user. This means that the user interface elements do not necessarily correspond to the translated language. But since the user decided on this language preference, it does not negatively affect the user, but actually supports the user when navigating the wiki. | ||
<gallery widths="500" heights="350"> | <gallery widths="500" heights="350"> | ||
Line 38: | Line 38: | ||
=== Adding the language switcher to a page === | === Adding the language switcher to a page === | ||
Now that we have two language versions, we want to connect them | Now that we have two language versions, we want to connect them with the language switcher. To add the language switcher to a page: | ||
# '''Open''' the page in edit mode. | # '''Open''' the page in edit mode. | ||
# '''Insert''' the template ''Languages'' form the editor toolbar. | # '''Insert''' the template ''Languages'' form the editor toolbar. | ||
Line 46: | Line 46: | ||
The language switcher now | The language switcher now shows what other languages are already available. | ||
[[File:languageswitcher-DE.png|alt=Language switcher shows all available translations|center|thumb| | [[File:languageswitcher-DE.png|alt=Language switcher shows all available translations|center|thumb|550x550px|The language switcher shows all available translations]] | ||
# | # | ||
# | # | ||
Line 65: | Line 65: | ||
Explanation of the arguments for this query: | Explanation of the arguments for this query: | ||
* '''<nowiki>[[:+]]</nowiki>''': Returns pages only in the main namespace. To show the pages form the entire wiki, simply delete this argument. | * '''<nowiki>[[:+]]</nowiki>''': Returns pages only in the main namespace. To show the pages form the entire wiki, simply delete this argument. Other options: | ||
**<nowiki>[[QM::+]]</nowiki>: Returns pages from the namespace QM | **<nowiki>[[QM::+]]</nowiki>: Returns pages from the namespace QM | ||
**<nowiki>[[QM:+||Help:+]]</nowiki>: Returns pages from the namespaces QM and Help. | **<nowiki>[[QM:+||Help:+]]</nowiki>: Returns pages from the namespaces QM and Help. | ||
Line 77: | Line 77: | ||
To see more examples for | To see more examples for defining and further modifying a query, go to our [[SMW queries|SMW-query examples]] page. | ||
== Creating portal pages based on user language settings == | == Creating portal pages based on user language settings == | ||
Portal pages are pages that serve as entry points to different topics or areas in the portal, often considering the needs of specific user groups. A typical example is the main page of the wiki, which | Portal pages are pages that serve as entry points to different topics or areas in the portal, often considering the needs of specific user groups. A typical example is the main page of the wiki, which should give users a high-level orientation in the wiki. A portal page is a good place to take the language needs of different users into account. | ||
Here, we can take two different approaches: | Here, we can take two different approaches: | ||
Line 95: | Line 95: | ||
=== Preparing the user language check === | === Preparing the user language check === | ||
Checking for the user language requires that we create a system message for this purpose. This needs to be done by users in the role ''admin'' or ''structuremanager'': | Checking for the user language requires that we create a system message for this purpose. This is easy to do, but needs to be done by users in the role ''admin'' or ''structuremanager.'' | ||
To create a system message for the user language: | |||
# '''Create''' the page ''MediaWiki:lang w''ith the content being the language code of the content language of your wiki. If you are not sure in what language your wiki was installed, you can add the magic word <nowiki>{{CONTENTLANGUAGE}}</nowiki> to the source of any wiki page and look at its output. If you have an English wiki, you need to add "en" as the content to this page. If your wiki is German, add "de" instead.[[File:message key-lang.png|alt=Page MediaWiki:Lang|center|thumb|650x650px|Page MediaWiki:Lang]] | # '''Create''' the page ''MediaWiki:lang w''ith the content being the language code of the content language of your wiki. If you are not sure in what language your wiki was installed, you can add the magic word <nowiki>{{CONTENTLANGUAGE}}</nowiki> to the source of any wiki page and look at its output. If you have an English wiki, you need to add "en" as the content to this page. If your wiki is German, add "de" instead.[[File:message key-lang.png|alt=Page MediaWiki:Lang|center|thumb|650x650px|Page MediaWiki:Lang]] | ||
Line 102: | Line 104: | ||
#* MediaWiki:Lang/fr | #* MediaWiki:Lang/fr | ||
Now | Now we have a mechanism to detect the user language. By checking for the value of the "[[mediawikiwiki:Help:Magic_words#Localization|magic word]]" <nowiki>{{int:lang}}</nowiki> , we can use it in many different scenarios. | ||
=== Displaying additional content === | === Displaying additional content === | ||
To show content on a page only to users with a specific language setting | To show content on a page only to users with a specific language setting — for example, German — we add the following check:<syntaxhighlight lang="text"> | ||
{{#ifeq: {{int:lang}}|de|show this content|}} | {{#ifeq: {{int:lang}}|de|show this content|}} | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== | === Switching to different page content === | ||
To show entirely different content to users with different language settings, you can prepare different pages and then serve them up as needed. As an example we take the homepage of the wiki. | To show entirely different content to users with different language settings, you can prepare different pages and then serve them up as needed. As an example we take the homepage of the wiki. | ||
Line 121: | Line 123: | ||
{{#switch: {{int:lang}}|de={{:Main Page/de}}|fr={{:Main Page/fr}}|{{:Main Page/en}} }} | {{#switch: {{int:lang}}|de={{:Main Page/de}}|fr={{:Main Page/fr}}|{{:Main Page/en}} }} | ||
</syntaxhighlight>Users with language setting "de" will see the content of page ''Main Page/de'', users with "fr" language setting the page ''Main Page/fr'', all other users get the page Main ''Page/en''. | </syntaxhighlight>Users with language setting "de" will see the content of page ''Main Page/de'', users with "fr" language setting the page ''Main Page/fr'', all other users get the page Main ''Page/en''. | ||
=== Switching labels === | |||
To show different labels or short text snippets directly on a page, we can also use the switch function:<syntaxhighlight lang="text"> | |||
{{#switch:{{int:lang}}|de=Überschrift 2|en=Heading 2}} | |||
</syntaxhighlight>To summarize, the following main page can be accomplished in two different ways: | |||
# By creating separate subpages for each user language and then transcluding them with a user language check on the actual Main Page. | |||
# By loading the actual Main Page and then building the language checks into the page itself. The following picture shows examples of: | |||
#* (1), (2) Switching headings | |||
#* (3) Displaying query results based on the tracked language from the language switcher template (e.g., <nowiki>[[Languages/tracklang::en]]</nowiki>) | |||
#* (4) Switching display labels in templates (this can also be applied to page forms) | |||
#* (5) Switching image captions | |||
[[File:usrelanguage-switchlabels.png|alt=Content based on user language settings|center|thumb|750x750px|Content based on user language settings]] | |||
=== Switching template and form labels === | |||
As the previous screenshot shows, labels in templates (and forms) can also be shown based on user language. You can simply add the switch function directly in the template. The template ''Template:Contactinfo'' collects street, zip and city info:<syntaxhighlight lang="text"> | |||
{| class="wikitable" | |||
! {{#switch:{{int:lang}}|en=Street|de=Straße}} | |||
| {{{street|}}} | |||
|- | |||
! {{#switch:{{int:lang}}|en=Zip|de=PLZ}} | |||
| {{{zip|}}} | |||
|- | |||
! {{#switch:{{int:lang}}|en=City|de=Stadt}} | |||
| {{{city|}}} | |||
|} | |||
</syntaxhighlight>It displays the different labels as needed:<gallery widths="180" heights="100"> | |||
File:uselang-template-en.png|alt=English labels|English labels | |||
File:uselang-template-de.png|alt=German labels|German labels | |||
</gallery> | |||
== Multilingual navigation == | == Multilingual navigation == |
Revision as of 13:24, 25 March 2022
A wiki can be set up to include different language versions of a wiki content. Wiki administrators have to make some decisions regarding how they want to support each wiki user's language setting in addition to simply providing translated content.
The following considerations refer to a single-wiki scenario and don't apply if the language versions are maintained in multiple wikis.
Concepts
To make a wiki multilingual, the some basic steps are necessary:
- Import a language switcher
- Create wiki pages with linked translation subpages
In addition, depending on your wiki setup, further aspects can and should be considered:
- Create page lists for each language with different filter settings
- Create portal pages based on user language
- Create template and form labels based on user language
- Create a multilingual category system
- Create multilingual navigation links
The following information gives you some suggestions for how to organise a wiki around its multilingual content based on these aspects. It does not consider using the MediaWiki extension Translate which is often installed in multlingual wikis to faciliate a section-by-section translation of wiki pages. If most of your wiki content needs consistently accurate translations, this extension can be valuable.
Importing the language switcher
To show that a page has different versions, it is useful to indicate this with a language switcher on each page. If you have no language switcher in your wiki, you can download a language switcher template. The techniques shown in the following sections assume that this language switcher is installed.
Be sure to read the configuration instructions on the downloads page. You need to define the languages that you want to support in the template.
Creating wiki pages with translated subpages
Let's take a page called Vacation policy and create a German language version as a subpage. After saving the page Vacation policy/de and providing the content translation, we have the German translation that we wanted. As you can see in the screenshots below, the page content is always shown in the context of the user language preferences of each user. This means that the user interface elements do not necessarily correspond to the translated language. But since the user decided on this language preference, it does not negatively affect the user, but actually supports the user when navigating the wiki.
Adding the language switcher to a page
Now that we have two language versions, we want to connect them with the language switcher. To add the language switcher to a page:
- Open the page in edit mode.
- Insert the template Languages form the editor toolbar.
- Enter a display title for the page (recommended for subpages).The search engine will index this display title so that the title search returns the expected result.
- Save the page.
- Repeat steps 1-4 with other language subpages (e.g, fr, nl).
The language switcher now shows what other languages are already available.
Creating page lists for different languages
Over time, a wiki can have lots of these translated pages. We want to make sure that users know what pages are available in what languages. For this purpose, the language switcher template includes a custom property Languages/tracklang that allows to easily create filtered page lists for this purpose.
Working with properties requires the Semantic MediaWiki extensions, which are bundled in BlueSpice pro, but not in BlueSpice free. There are, however, alternative approaches for creating page lists in BlueSpice free.
In BlueSpice pro, you can include different inline queries on any wiki page. This example lists German language pages in the main namespace and displays them in a category-type output (A-Z listing):
{{#ask:
[[:+]][[Languages/tracklang::de]]
|format=category
}}
Explanation of the arguments for this query:
- [[:+]]: Returns pages only in the main namespace. To show the pages form the entire wiki, simply delete this argument. Other options:
- [[QM::+]]: Returns pages from the namespace QM
- [[QM:+||Help:+]]: Returns pages from the namespaces QM and Help.
- [[Languages/tracklang::de]]: Returns only pages that are marked by the language switcher template as German language pages. Other options:
- [[Languages/tracklang::+]]: Returns all language pages that are tracked in the wiki by the language switcher template.
- [[Languages/tracklang::!de]]: Returns all language pages except German pages.
- [[Languages/tracklang::de||fr]]: Returns all language pages in German and French (in the example above restricted to the main namespace.
- format=category: returns a category style output.
- format=ul: returns a list style output
To see more examples for defining and further modifying a query, go to our SMW-query examples page.
Creating portal pages based on user language settings
Portal pages are pages that serve as entry points to different topics or areas in the portal, often considering the needs of specific user groups. A typical example is the main page of the wiki, which should give users a high-level orientation in the wiki. A portal page is a good place to take the language needs of different users into account.
Here, we can take two different approaches:
- Show the same page to all users, but include some content that targets specific user languages.
- Show completely separate content to users based on their user language.
What is the user language?
Wiki users can change their own language setting in the user preferences:
Depending on this setting, users then see the user interface elements in that language as we have seen in previous screenshots. This applies to interface elements that already have translated system messages.
To provide additional support for this setting, we can include checks on wiki pages that determine the user language and serve up additional or alternative information as needed.
Preparing the user language check
Checking for the user language requires that we create a system message for this purpose. This is easy to do, but needs to be done by users in the role admin or structuremanager.
To create a system message for the user language:
- Create the page MediaWiki:lang with the content being the language code of the content language of your wiki. If you are not sure in what language your wiki was installed, you can add the magic word {{CONTENTLANGUAGE}} to the source of any wiki page and look at its output. If you have an English wiki, you need to add "en" as the content to this page. If your wiki is German, add "de" instead.
- Create subpages to this page for the user languages you want to support. For example in an English wiki:
- MediaWiki:Lang/de
- MediaWiki:Lang/fr
Now we have a mechanism to detect the user language. By checking for the value of the "magic word" {{int:lang}} , we can use it in many different scenarios.
Displaying additional content
To show content on a page only to users with a specific language setting — for example, German — we add the following check:
{{#ifeq: {{int:lang}}|de|show this content|}}
Switching to different page content
To show entirely different content to users with different language settings, you can prepare different pages and then serve them up as needed. As an example we take the homepage of the wiki.
To display different homepage content based on user language in an English wiki, where the homepage is called Main Page:
- Create a subpage for each language you want to support, e.g.
- Main Page/en
- Main Page/de
- Main Page/fr
- On the page Main Page, add the following switch:Users with language setting "de" will see the content of page Main Page/de, users with "fr" language setting the page Main Page/fr, all other users get the page Main Page/en.
{{#switch: {{int:lang}}|de={{:Main Page/de}}|fr={{:Main Page/fr}}|{{:Main Page/en}} }}
Switching labels
To show different labels or short text snippets directly on a page, we can also use the switch function:
{{#switch:{{int:lang}}|de=Überschrift 2|en=Heading 2}}
To summarize, the following main page can be accomplished in two different ways:
- By creating separate subpages for each user language and then transcluding them with a user language check on the actual Main Page.
- By loading the actual Main Page and then building the language checks into the page itself. The following picture shows examples of:
- (1), (2) Switching headings
- (3) Displaying query results based on the tracked language from the language switcher template (e.g., [[Languages/tracklang::en]])
- (4) Switching display labels in templates (this can also be applied to page forms)
- (5) Switching image captions
Switching template and form labels
As the previous screenshot shows, labels in templates (and forms) can also be shown based on user language. You can simply add the switch function directly in the template. The template Template:Contactinfo collects street, zip and city info:
{| class="wikitable"
! {{#switch:{{int:lang}}|en=Street|de=Straße}}
| {{{street|}}}
|-
! {{#switch:{{int:lang}}|en=Zip|de=PLZ}}
| {{{zip|}}}
|-
! {{#switch:{{int:lang}}|en=City|de=Stadt}}
| {{{city|}}}
|}
It displays the different labels as needed:
Currently, there is no easy mechanism to create multilingual navigation menus, such as the main navigation or the custom menu. More support should be coming in one of the next minor releases of BlueSpice (4.1.3 or 4.1.4). In the meantime, you can create individual links based on a user's language settings.