Control modules based on JoomFish or front-end language |
|
Joomla is capable of being set up in various languages. These recipes demonstrate how to display different modules depending on the “front-end language” as chosen by the administrator, or by the user via a language selector (e.g. via JoomFish). They also demonstrate how to display different modules based on the language set up in the user’s browser, so as to target your users with modules in their own language. Using MetaMod to control modules by language is a useful addition to JoomFish’s translation capabilities. Instead of just translating each item in a menu into each language, just set up an entire “duplicate menu” for each alternative language, and use MetaMod to switch the entire menu to a different one, depending on the language the user has selected. This has the additional advantage that you can have some completely different menu items in each language which is often useful, as the audiences in each language might be quite different. Of course, this depends on the menus being controlled in Module Positions – note that some templates out there (e.g. RocketTheme) embed the main menus into the template itself, so cannot be controlled with MetaMod.
if ( $language == "en-gb" ) return 101; /* British English only */ if ( $language_code == "en" ) return 102; /* any variant of English */ /* or, any language in Switzerland: de-ch, fr-ch, it-ch: */ if ( $language_region == "ch" ) return 103;
if ( $language == "ar" ) return 101; /* Arabic */ if ( $language == "fr" ) return 102; /* French */
|



