Thread Rating:
  • 3 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Support for multilanguage sites, Internationalization (I18N)
#1
Yesterday I installed GetSimple and didn't find support for multilanguage sites.
So I've created a plugin http://get-simple.info/extend/plugin/i18n/69/, which adds multilanguage support and hierarchical menus to your website.

The language is determined by the language in the user session (if previously set with the URL parameter "setlang") and the http accept language header. By using the URL parameter "lang" this can be overridden for the current request.

If you want to show the language in the URL, see here.

Installation

Copy i18n.php to your plugin directory, change the constant I18N_DEFAULT_LANGUAGE in i18n.php, and replace the following functions in your template(s):
  • get_component with get_i18n_component
  • get_navigation with get_i18n_navigation

Usage

To internationalize a page,
  • create another page with the same slug/URL and the 2-letter language code separated by a "_" (e.g. for page "index" create another one "index_it" for italian),
  • set its meta data, esp. the title and the menu text.
  • The properties "parent page", "template" and "add to menu" are ignored, the properties of the base page (without language) are used instead.

The base page (without language) is assumed to be in the language specified as I18N_DEFAULT_LANGUAGE in i18n.php.

To use the internationalized hierarchical menu,
  • ensure that the hierarchical structure of the base pages (without language) is set up correctly (property "parent page"),
  • the "add to menu" property of the relevant base pages is checked,
  • all language pages have at least the "title" property set,
  • add to your template(s) "get_i18n_navigation(return_page_slug(), minlevel, maxlevel)", e.g.
    • "get_i18n_navigation(return_page_slug(),0,0)" for your top level menu in the header, and
    • "get_i18n_navigation(return_page_slug(),1,10)" for the remaining menu levels in the sidebar menu
  • for a menu, which should only contain entries, which are available for the current language use "get_i18n_navigation(return_page_slug(),0,10,I18N_SHOW_LANGUAGE)"
  • for a site map use "get_i18n_navigation(return_page_slug(),0,10,I18N_SHOW_PAGES)" (all pages, menu texts) or "get_i18n_navigation(return_page_slug(),0,10,I18N_SHOW_TITLES)" (all pages, titles) or "get_i18n_navigation(return_page_slug(),0,10,I18N_SHOW_MENU)" (only the pages visible in the menu).

get_i18n_navigation adds the following css classes to the list items:
  • slug of the page
  • slug of the page's parent
  • "current", if the page is the current page
  • "currentpath", if the page is a parent, grandparent, etc. of the current page
  • "open", if the page has children whose menu items are currently displayed
  • "closed", if the page has children whose menu items are currently not displayed

If you want a one-level menu only, you have to make sure that all your base pages that are in the menu have "--- None ---" as parent.

Problem Solving
  • Make sure your site URL in the GetSimple admin settings is correct - otherwise language switching might not work.

If, when visiting the site (with Chrome), the languages switches back to the default language, after you have switched to another language (with parameter setlang=...)
  • make sure that you have a favicon.ico on your site. Requesting favicon.ico MUST NOT return the GetSimple not-found page!
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply


Messages In This Thread
Support for multilanguage sites, Internationalization (I18N) - by mvlcek - 2011-01-09, 06:07:56
rewrite language problem - by tomkop - 2013-03-27, 06:34:44
Enhancement suggestion - by hameau - 2013-05-12, 04:17:12
Enhancement request - by hameau - 2013-06-14, 20:02:07
RE: Enhancement request - by mvlcek - 2013-06-14, 22:04:12
RE: Enhancement request - by hameau - 2013-06-14, 23:01:36
Duplicate language cookies bug - by enzy - 2013-08-20, 07:03:26
RE: Duplicate language cookies bug - by ohayo - 2013-08-20, 18:12:25
Plugin is not shown - by tosho - 2013-09-15, 12:10:37
1000 pages limit in i18n_navigation - by titus - 2014-10-13, 21:58:36
Bug found - by lbarsov - 2014-10-17, 03:41:53
Menu with picture - by Dimi - 2015-04-28, 16:05:45
Rendering Menu in Component - by Alexander_ - 2016-05-04, 23:06:51
Meta desc for different languages - by Alexander_ - 2017-02-14, 20:29:32
Hierarchical Menus - by celextel - 2019-07-26, 16:41:47
Ri18n_navigation - by celextel - 2021-02-19, 16:07:48



Users browsing this thread: 1 Guest(s)