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):
Usage
To internationalize a page,
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,
get_i18n_navigation adds the following css classes to the list items:
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
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=...)
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
- "get_i18n_navigation(return_page_slug(),0,0)" for your top level menu in the header, and
- 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!