J2.5

Difference between revisions of "Language Switcher Tutorial"

From Joomla! Documentation

Line 1: Line 1:
 
Joomla 1.6 includes a basic way to implement a multi-language site. This feature does not work as an association-type display where each content, whatever it is, has an equivalent in another language (it does not replace other extensions as Joomfish).   
 
Joomla 1.6 includes a basic way to implement a multi-language site. This feature does not work as an association-type display where each content, whatever it is, has an equivalent in another language (it does not replace other extensions as Joomfish).   
  
This is why using the Language Switcher Module to change language is set to redirect to another Content Language Home Page. To be able to implement the feature, 5 aspects have to be dealt with.   
+
This is why using the Language Switcher Module to change language is set to redirect to another Content Language Home Page. To be able to implement the feature, 7 aspects have to be dealt with.   
 
# The Content Language parameters in the Language Manager   
 
# The Content Language parameters in the Language Manager   
 
# Assigning these Content languages to various items using the "Language" parameter.   
 
# Assigning these Content languages to various items using the "Language" parameter.   

Revision as of 05:16, 23 February 2011

The "J2.5" namespace is a namespace scheduled to be archived. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.

Joomla 1.6 includes a basic way to implement a multi-language site. This feature does not work as an association-type display where each content, whatever it is, has an equivalent in another language (it does not replace other extensions as Joomfish).

This is why using the Language Switcher Module to change language is set to redirect to another Content Language Home Page. To be able to implement the feature, 7 aspects have to be dealt with.

  1. The Content Language parameters in the Language Manager
  2. Assigning these Content languages to various items using the "Language" parameter.
  3. Defining a Default Home page Menu item per language
  4. The languagefilter System Plugin
  5. The mod_languages Module (also called Langswitcher)
  6. Define a default site template per Content language if needed.
  7. Make sure the site language packs are installed and enabled for any content language you want to display

The "Content" tab in Language Manager[edit]

There, one can create a "Content Language", even if the site language is not yet installed.

  • Title = The name of the language as it will appear in the dropdown lists when assigning the language to an item. This Title will also be used by the langswitcher module in front-end when flags are not used.
  • Title Native = A title in any language desired by the admin to be displayed in the Content Language list.
  • URL Language Code= This Language Code will be appended to the site url. When SEF is enabled, one will get  http://mysite.com/en/. If SEF is disabled the suffix &lang=en will be appended at the end of the URL. Note the Language Code must be unique among all the languages.
  • Image Prefix = Prefix of the image file for this language when using the "Use image flags" Language Switcher basic option. Example: if 'en' is chosen, then the image shall be en.gif. Images and CSS for this module are in media/mod_languages/ . Users can add any image/flag there with any prefix. Example: pt_br for the Brazilian flag.
  • Language Tag = Enter here the language tag example: en-GB for English (UK). This should be the exact prefix used for the language installed or to be installed.
  • Published = Whether this content language is published or not. If published, it will display as a choice in the Language Switcher module in frontend. To work OK, the specific site language must be installed. One can prepare contents in a specific Content Language without even installing the language concerned, and just do it when deciding to publish that language.
  • Metadata = These metadata definitions will override Global Configuration Metadata in Multilanguage configuration for each language used.

The "Language" parameter in 1.6[edit]

Not only Articles but everything is taggable to a specific Content language. Modules obviously but also Categories, Banners, Weblinks, Newsfeeds, Menu Items...

Defining a Default Home page Menu item per language[edit]

As the Language Switcher Module is set to redirect to another Content Language Home Page, one has to be defined for each language.

Important Note: A default Menu containing a Home page menu item taggged to "All" should still exist, and the menu module displaying it should not be published.

The languagefilter System Plugin[edit]

This plugin filters the displayed content depending on language. This plugin is to be enabled -only- when the Language Switcher module is published.

The mod_languages Module (also called Langswitcher)[edit]

This module displays a list of available Content Languages (as defined and published in Language Manager Content tab) for switching between them when one wants to use Joomla! as a multilanguage site.

The plugin 'System - Language Filter' has to be published. When switching languages, the module redirects to the Home page defined for the chosen language. Thereafter, the navigation will be the one defined for that language. If the plugin 'System - Language Filter' is unpublished, this may have unwanted results. Method:

  • Open Language Manager Content tab and make sure the Languages you want to use in contents are published and have a prefix for the URL as well as prefix for the image used in the module display.
  • Create a Home page by assigning a language to a menu item and defining it as Default Home page for each published content language.
  • Thereafter, you can assign a language to any Article, Category, Module, Newsfeed, Weblinks in Joomla.
  • Assign the Langswitcher module to each Specific Default Language Content Home page and param it to use flags or text to display the choice in front-end.
  • New parameters for 1.6.1: display or not the active language, choose between horizontal and vertical display.

* Make sure both the module and the plugin are published.

Define a default site template per Content language[edit]

If one wants to use different templates styles per Content language, instead of defining for each menu item a different template style, one can assign globally a template style per language when editing it in the Template Manager. This is very handy when one needs to use different headers, logos, etc. for each Content language. It also covers any issue arising from loading a page not linked to any menu item where the default template style would be used, whatever it is.

Install the necessary site language packs[edit]

Last but not least, each content language to be displayed should have the Joomla site language pack installed and enabled.

How to Test (in beta 1.6)[edit]

Obviously, Sample data is not the best way to demonstrate easily the power of this new Feature. But one can test a simple site with the following actions using the temporary test language xx-XX. One prerequisite is that it should remain a Home menu item tagged to "All" and defined as default Home, the module displaying it being unpublished or assigned to a non available position in the template

  1. Define CONTENT LANGUAGES in the Language Manager, URL Language code for the url and flag for each. Default available are en-GB and xx-XX.
  2. Create a Parent Article Category tagged to en-GB and one tagged to xx-XX
  3. Create articles in each of these categories, tagging the articles to the same language as the category.
  4. If you like, create sub categories with articles, all tagged as should.
  5. Create one menu per language, tagged as should. This will create 2 menu modules. Tag them to the language concerned.
  6. Create menu items tagged to that language in each menu. For now variations of the Article menu items (blog, list, single...)
  7. Define one menu item per language/menu as the Home for this language.
  8. Publish the langswitcher module (tagged to language "All") and assign ONLY to each Content Language Home Menu Item (Parks Home and Fruitshop Welcome in the fast test)
  9. Publish the languagefilter plugin.


Tip for a fast test: [Tag the Park Home menu item to en-GB and as Default Home, same for the Fruitshop Welcome menu item tagged to xx-XX and set as default home for this language. Make sure the langfilter plugin is published and that the langswitcher module is published and assigned to position7 for the 2 home pages]