Templates download/Language switcher: Difference between revisions

(Created page with "<nowiki><div class="downloadarea"></nowiki> <nowiki><span class="getButton">Download</nowiki><nowiki></span></nowiki> <nowiki>File:HW...")
 
No edit summary
 
(11 intermediate revisions by the same user not shown)
Line 1: Line 1:
<nowiki><div class="downloadarea"></nowiki>
{{Textbox|boxtype=note|header=|text=Starting with BlueSpice 4.3, a language switcher is automatically created for subpages or interlanguage links and this template is no longer needed.|icon=yes}}<div class="downloadarea">
<span class="getButton">[[Media:HW-LanguageSwitcher.zip|Download]]</span>


<nowiki><span class="getButton">[[Media:HW-LanguageSwitcher-de.zip|Download]]</nowiki><nowiki></span></nowiki>
[[File:HW-languageswitcher.png|350x350px|alt=language switcher screenshot]]
</div>This download file includes two versions of a language switcher. Supported languages can be defined in the templates.


==Importing the template==
The import file is included in the archive file ''HW-LanguageSwitcher.zip''. Unpack the zip file first.


<nowiki>[[File:HW-languageswitcher.png|350x350px]]</nowiki>
On the page ''Special:Import'' follow these steps:


<nowiki></div></nowiki>This template creates a link that is styled as a button. It can be inserted into a  wiki page via the VisualEditor <nowiki>''</nowiki>Insert > Template<nowiki>''</nowiki> menu.
#'''Select file''' and choose ''HW-LanguageSwitcher.xml''.
 
#'''Enter''' an Interwiki prefix. Since this field is required, simply add ''hw'' (for hallowelt).
<nowiki>==Importing the template==</nowiki>
#'''Keep''' the selection ''Import to default locations''.
 
#'''Click''' ''Upload file...'' .
The import file is included in the archive file <nowiki>''</nowiki>HW-ButtonLink.zip<nowiki>''</nowiki>. Unpack the zip file first.
 
 
On the page <nowiki>''</nowiki>Special:Import<nowiki>''</nowiki> follow these steps:
 
 
<nowiki>#</nowiki><nowiki>'''</nowiki>Select file<nowiki>'''</nowiki> and choose <nowiki>''</nowiki>HW-ButtonLink.xml<nowiki>''</nowiki>.
 
<nowiki>#</nowiki><nowiki>'''</nowiki>Enter<nowiki>'''</nowiki> an Interwiki prefix. Since this field is required, simply add <nowiki>''</nowiki>hw<nowiki>''</nowiki> (for hallowelt).
 
<nowiki>#</nowiki><nowiki>'''</nowiki>Keep<nowiki>'''</nowiki> the selection <nowiki>''</nowiki>Import to default locations<nowiki>''</nowiki>.
 
<nowiki>#</nowiki><nowiki>'''</nowiki>Click<nowiki>'''</nowiki> <nowiki>''</nowiki>Upload file...<nowiki>''</nowiki> .
 
 
The template is now available in your wiki.<nowiki>{{Messagebox|boxtype=important|Note text=The input fields for the template parameters are usually not automatically available after importing the template to your wiki . You have to open the imported template file and make an edit (e.g., add a space and then save the page) to activate the template data functionality. The input fields should now be displayed correctly when you use the template on a page.}}</nowiki>
 
<nowiki>==Pages included in the import==</nowiki>


The templates are now available in your wiki.
==Pages included in the import==
The xml import creates the following files in your wiki:
The xml import creates the following files in your wiki:


* Template:Languages
* Template:Languages/styles.css
* Template:InterLanguages
* Property:Languages/tracklang
* MediaWiki:Lang
* MediaWiki:Lang/de
* MediaWiki:Lang/en
* MediaWiki:Lang/fr
* MediaWiki:Lang/nl


<nowiki>*</nowiki>Template:ButtonLink
== How it works ==
 
 
<nowiki>==Using the template==</nowiki>
 
 
<nowiki>#</nowiki>Add the template from the  <nowiki>[[Manual:Extension/VisualEditor|VisualEditor]]</nowiki> insert-dialog.
 
<nowiki>#</nowiki>Fill in the form fields as needed.
 
 
<nowiki>[[File:HW-ButtonLink-templatedata.png|center|thumb|450x450px|Insert-dialog for button link|link=Special:FilePath/HW-ButtonLink-templatedata.png]]</nowiki>
 
 
<nowiki>===Settings===</nowiki>
 
<nowiki>{| class="contenttable-blue" style="width:100%;"</nowiki>
 
! style="width:200px;" |Input field
 
!Description
 
|-
 
| style="width:200px;" |Is this an external link?
 
|yes = the link target starts with http:// or https://
 
Leave blank for internal wiki page
 
|-
 
| style="width:200px;" |Link target
 
|Name of the wiki page or the website
 
|-
 
| style="width:200px;" |Label


|Label shown on the button
=== Template:Languages ===
This template is used to switch between a page and its translated versions when the translations are maintained as subpages.


|-
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 "cl" 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 lowercase l (for language)  "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. For Spanish, you would define:<syntaxhighlight lang="text">
{{#vardefine:l4|es}}
</syntaxhighlight>
* After defining the variables, you need to add them to the actual switcher:<syntaxhighlight lang="text">
{{#switch: {{SUBPAGENAME}}
|{{#var:l1}}={{#var:switcher}}
|{{#var:l2}}={{#var:switcher}}
|{{#var:l3}}={{#var:switcher}}
|{{#var:l4}}={{#var:switcher}}
|{{#var:clswitcher}}}}
</syntaxhighlight>
*A tracking property enssures that the different languages are available for further processing through Semantic MediaWiki. This allows to create page lists of the different languages.:<syntaxhighlight lang="text">
<!-- set tracking property //-->
[[Languages/tracklang::{{#switch: {{SUBPAGENAME}}|{{#var:l1}}={{#var:l1}}|{{#var:l2}}={{#var:l2}}|{{#var:l3}}={{#var:l3}}|{{#var:l4}}={{#var:l4}}|{{#var:cl}}}}]]
</syntaxhighlight>


| style="width:200px;" |Background color
*Alternatively, especially in BluesSpice free (where no SMW functions and therefore no attributes are available by default), tracking categories can be used. These are commented out in the template by default. The comment must therefore be removed and all languages tracked as a category:<syntaxhighlight lang="text">
{{#switch: {{SUBPAGENAME}}|{{#var:l1}}=[[Category:{{#var:l1}}]]|{{#var:l2}}=[[Category:{{#var:l2}}]]|{{#var:l3}}=[[Category:{{#var:l3}}]]|{{#var:l4}}=[[Category:{{#var:l4}}]]|[[Category:{{#var:cl}}]]}}
</syntaxhighlight>
* In addition, you should add the language to the template description for the extension [[Reference:TemplateData|TemplateData]]:<syntaxhighlight lang="text">
"description": {
        "en": "Language switcher",
"de": "Sprachwechsler",
"fr": "Sélecteur de langue",
"nl": "Taal verandering",
"es": "Cambiador de idioma"
}
</syntaxhighlight>


|Possible button colors: red, blue (leave blank for white)
=== Template:InterLanguages ===
This template is used to switch between a page and its translated versions when the translations are not maintained as subpages, but are technically not associated at all.


|}
The template defines some variables to determine which languages you want to support.  '''The variable "self" defines the current page. It is required and must not be deleted.'''


The language variables are defined just like in the template Languages. If you define additional language variables, the newly defined languages has to be added to the language menu. The links are created in the following container:<syntaxhighlight lang="text">
<div id="langbar-hz">
...
</div>
</syntaxhighlight>Simply add each language with the l-number matching your language variable by copying this line and replacing the number:<syntaxhighlight lang="text">
{{#if: {{{pgnamel4|}}}|{{#switch:{{{pgnamel4|}}}|{{#var:self}}=[[{{FULLPAGENAME}}{{!}}{{#var:l4}}]]|[[{{{pgnamel4}}}{{!}}{{#var:l4}}]]}}|}}
</syntaxhighlight>In addition, you need to add the language to the template description and the available fields in the TemplateData editor.


In source editing mode:


<nowiki><br /></nowiki>
# '''Click''' ''Manage TemplateData''[[File:interlanguages-manageTD.png|alt=Manage TemplateData|center|thumb|650x650px|Manage TemplateData]]<br />
# '''Click''' ''Add parameter''[[File:interlanguages-manageTD-addparam.png|alt=Add new languages (as parameters)|center|thumb|514x514px|Add new languages (as parameters)]]
# '''Select''' any new language you have added and click '''Apply'''.[[File:interlanguages-manageTD-editparam.png|alt=Selecting a newly added paramter|center|thumb|515x515px|Selecting a newly added paramter]]
# '''Add''' the language abbreviation for the new language as a label and activate the ''Suggested'' checkbox and click '''Done.'''[[File:interlanguages-manageTD-paraminfo.png|alt=Parameter settings|center|thumb|521x521px|Parameter settings]]
# '''Click''' ''Add language'' to add a new template description for this language.[[File:interlanguages-manageTD-addlang.png|alt=adding a template description|center|thumb|450x450px|adding a template description]]
# '''Select''' the user language that corresponds to the current language parameter.[[File:interlanguages-manageTD-addlang-es.png|alt=select user language|center|thumb|450x450px|select user language]]<br />
# '''Enter''' a template description and click '''Apply'''. This description is shown when the user selects a template in the visual editor.[[File:interlanguages-manageTD-addlang-es-desc.png|alt=template description|center|thumb|450x450px|template description]]
{{Messagebox|boxtype=important|icon=|Note text=If you have changed the original default values for the language variables, make sure to change the language labels here accordingly. The labels for the l1, l2, l3,... languages need to match.<br/>[[File:interlanguages-manageTD-labels.png|alt=check correct language associations|center|thumb|250x250px|check correct language associations]]|bgcolor=}}


==Alignment of the language switcher==
By default, the language switcher appears on the right side of the page. To display it on the left side, change the following line in the page Template:Languages/styles.css:<syntaxhighlight lang="css">
#langbar-hz {text-align: left;}
</syntaxhighlight>


<nowiki>__NOTOC__</nowiki>
== Adding the language switcher to a page ==
It is possible to use both language switchers in the same wiki. They connect language versions in different scenarios:
*[[Multilingual wiki#Creating wiki pages with translated subpages|Using the language switcher template '''Languages''']] (for language versions that are maintained as subpages)
*[[Multilingual wiki#Connecting unrelated wiki pages|Using the language switcher template '''InterLanguages''']] (for language versions that are maintained as independent pages)
__NOTOC__

Latest revision as of 09:26, 21 July 2023

Starting with BlueSpice 4.3, a language switcher is automatically created for subpages or interlanguage links and this template is no longer needed.

This download file includes two versions of a language switcher. Supported languages can be defined in the templates.

Importing the template

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:

  1. Select file and choose HW-LanguageSwitcher.xml.
  2. Enter an Interwiki prefix. Since this field is required, simply add hw (for hallowelt).
  3. Keep the selection Import to default locations.
  4. Click Upload file... .

The templates are 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
  • Template:InterLanguages
  • Property:Languages/tracklang
  • MediaWiki:Lang
  • MediaWiki:Lang/de
  • MediaWiki:Lang/en
  • MediaWiki:Lang/fr
  • MediaWiki:Lang/nl

How it works

Template:Languages

This template is used to switch between a page and its translated versions when the translations are maintained as subpages.

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 "cl" 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 lowercase l (for language) "l1", "l2",.... The value needs to be provided as the ISO 639-1 language code for the language. For Spanish, you would define:
    {{#vardefine:l4|es}}
    
  • After defining the variables, you need to add them to the actual switcher:
    {{#switch: {{SUBPAGENAME}}
    |{{#var:l1}}={{#var:switcher}}
    |{{#var:l2}}={{#var:switcher}}
    |{{#var:l3}}={{#var:switcher}}
    |{{#var:l4}}={{#var:switcher}}
    |{{#var:clswitcher}}}}
    
  • A tracking property enssures that the different languages are available for further processing through Semantic MediaWiki. This allows to create page lists of the different languages.:
    <!-- set tracking property //-->
    [[Languages/tracklang::{{#switch: {{SUBPAGENAME}}|{{#var:l1}}={{#var:l1}}|{{#var:l2}}={{#var:l2}}|{{#var:l3}}={{#var:l3}}|{{#var:l4}}={{#var:l4}}|{{#var:cl}}}}]]
    
  • Alternatively, especially in BluesSpice free (where no SMW functions and therefore no attributes are available by default), tracking categories can be used. These are commented out in the template by default. The comment must therefore be removed and all languages tracked as a category:
    {{#switch: {{SUBPAGENAME}}|{{#var:l1}}=[[Category:{{#var:l1}}]]|{{#var:l2}}=[[Category:{{#var:l2}}]]|{{#var:l3}}=[[Category:{{#var:l3}}]]|{{#var:l4}}=[[Category:{{#var:l4}}]]|[[Category:{{#var:cl}}]]}}
    
  • In addition, you should add the language to the template description for the extension TemplateData:
    "description": {
            "en": "Language switcher",
    		"de": "Sprachwechsler",		
    		"fr": "Sélecteur de langue",
    		"nl": "Taal verandering",
    		"es": "Cambiador de idioma"
    	}
    

Template:InterLanguages

This template is used to switch between a page and its translated versions when the translations are not maintained as subpages, but are technically not associated at all.

The template defines some variables to determine which languages you want to support. The variable "self" defines the current page. It is required and must not be deleted.

The language variables are defined just like in the template Languages. If you define additional language variables, the newly defined languages has to be added to the language menu. The links are created in the following container:

<div id="langbar-hz">
...
</div>

Simply add each language with the l-number matching your language variable by copying this line and replacing the number:

{{#if: {{{pgnamel4|}}}|{{#switch:{{{pgnamel4|}}}|{{#var:self}}=[[{{FULLPAGENAME}}{{!}}{{#var:l4}}]]|[[{{{pgnamel4}}}{{!}}{{#var:l4}}]]}}|}}

In addition, you need to add the language to the template description and the available fields in the TemplateData editor.

In source editing mode:

  1. Click Manage TemplateData
    Manage TemplateData
    Manage TemplateData

  2. Click Add parameter
    Add new languages (as parameters)
    Add new languages (as parameters)
  3. Select any new language you have added and click Apply.
    Selecting a newly added paramter
    Selecting a newly added paramter
  4. Add the language abbreviation for the new language as a label and activate the Suggested checkbox and click Done.
    Parameter settings
    Parameter settings
  5. Click Add language to add a new template description for this language.
    adding a template description
    adding a template description
  6. Select the user language that corresponds to the current language parameter.
    select user language
    select user language

  7. Enter a template description and click Apply. This description is shown when the user selects a template in the visual editor.
    template description
    template description
Important!If you have changed the original default values for the language variables, make sure to change the language labels here accordingly. The labels for the l1, l2, l3,... languages need to match.
check correct language associations
check correct language associations


Alignment of the language switcher

By default, the language switcher appears on the right side of the page. To display it on the left side, change the following line in the page Template:Languages/styles.css:

#langbar-hz {text-align: left;}

Adding the language switcher to a page

It is possible to use both language switchers in the same wiki. They connect language versions in different scenarios:



To submit feedback about this documentation, visit our community forum.