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
#2
A new version (0.7) is available, which adds an I18N view on the admin pages tab, which shows all pages and their language variants in a table.

Installation (additional)

To make best use of the add links on the I18N view (some fields prefilled), you must patch the file admin/edit.php as follows:

Code:
...
if ($id)
{
  ...
}
else
{
  // --- add the following lines
  if (isset($_GET['parent'])) $parent = $_GET['parent'];
  if (isset($_GET['template'])) $template = $_GET['template'];
  if (isset($_GET['metak'])) $metak = $_GET['metak'];
  if (isset($_GET['metad'])) $metad = $_GET['metad'];
  if (isset($_GET['menu-enable'])) $menuStatus = $_GET['menu-enable'];
  if (isset($_GET['menu-order'])) $menuOrder = $_GET['menu-order'];
  if (isset($_GET['private'])) $private = $_GET['private'];
  if (isset($_GET['title'])) $title = $_GET['title'];
  if (isset($_GET['menu'])) $menu = $_GET['menu'];
  if (isset($_GET['newid'])) $url = $_GET['newid'];
  // --- add end
  $buttonname = $i18n['BTN_SAVEPAGE'];
}
...
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
#3
looks really interesting. Will test this soon
Reply
#4
A new version (0.8) is available, which simplifies the selection of a parent page and the position in the menu and allows any number of levels in your page structure.

A demonstration and screen shots can be found on http://mvlcek.bplaced.net.

Installation (changes)

Just unzip the plugin zip into your plugins directory.
The file admin/edit.php does NOT need to be changed any more!
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
#5
Works like a charm! Thank you very much for this nice plugin! Smile
Reply
#6
Yes, the plugin useful and works well
Reply
#7
does it cache the menu structure ?
Reply
#8
how to switch languages and components for the language to do?
Reply
#9
marrco Wrote:does it cache the menu structure ?

Yes, it does.
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
#10
Oleg06 Wrote:how to switch languages and components for the language to do?

Not sure, if I understand your question correctly: The language is automatically switched based on the user's language preferences in the browser. If the site is e.g. english (default) and german and the user's prefered languages are italian and german, he will see the german page, if they are italian and spanish, he will see the default language (english).

You can also switch languages for the next request or for the current session, see http://mvlcek.bplaced.net/get-simple/i18n/ at the bottom of the page.
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
#11
I created a pages index_de and index_ru, written links and and
but somehow it does not work
teach me please :-)
Reply
#12
Your language links use neowebtime instead of neowebtime.ru
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
#13
Big Grin thanks, works
Reply
#14
охренеть, plugin is excellent, wonderful
Reply
#15
I have uploaded a new version, which also has functions to display breadcrumbs.

See http://mvlcek.bplaced.net/multi-level-na...eadcrumbs/ for a demo and details.
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
#16
Hi!

Thanks for plugin. I have a question...

How can I call language name from a template?

I need to add something to a template when specific language is active.

Sorry, I don't know php Smile
Reply
#17
iggy Wrote:Hi!
I need to add something to a template when specific language is active.

There is a global variable $language set, if the current language is not the default language, thus use for a non-default language 'de':

Code:
<?php if (isset($language) && $language == 'de') { ?>
...
<?php } ?>

and for the default language:

Code:
<?php if (!isset($language)) { ?>
...
<?php } ?>
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
#18
This isn't a bug but It should be improved: When you try to name a new page with a "_" (e.g. index_en) it automatically hides the "Template" options. This can be a problem, for example I wanted to use a different template for the main page and its English version but I couldn't because of this.
GS fan
Reply
#19
ldac Wrote:This isn't a bug but It should be improved: When you try to name a new page with a "_" (e.g. index_en) it automatically hides the "Template" options. This can be a problem, for example I wanted to use a different template for the main page and its English version but I couldn't because of this.

Currently it is not possible to use different templates for languages with the I18N plugin, which is the reason, why the option is hidden. As the default language is used when a translation is not available, the different templates shouldn't have many differences in any case, lest the user be baffled by the layout changing between pages.

Why do you want to have a different template?

If it's just for small differences, you can include conditionals like

Code:
<?php if ($language == 'de') { ?>...<?php } ?>

in your template.
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
#20
Hello,
thanks mvlcek for this plugin!

But it doesn't seem to work with the new beta "GetSimple_3.0Beta_r323". Btw thats the only beta version I tried it with.

The problem is, I can't create a page called something_en, because the slug/URL with somehow "loose" the underscore after clicking on save.
Reply
#21
I've high problem with the installation of this plugin.
I use Get Simple 2.0.1 and I18N Plugin 0.9.1, but in administration page the file editextras.php stop his code print to the first line of XML section.
The result is that the plugin is totally unusable because whene I would to create a new page I can see only the title input and the link "Options", but I can't see all the form.
Where is the problem?
Reply
#22
ultrastudio Wrote:I've high problem with the installation of this plugin.
I use Get Simple 2.0.1 and I18N Plugin 0.9.1, but in administration page the file editextras.php stop his code print to the first line of XML section.
The result is that the plugin is totally unusable because whene I would to create a new page I can see only the title input and the link "Options", but I can't see all the form.
Where is the problem?

I've resolve: sorry all, the solution was update core to the new stable version of GetSimple.
Well, this plugin is actually compatible with GetSimple 2.03.1 and not with GetSimple 2.01.
Reply
#23
Texta Wrote:But it doesn't seem to work with the new beta "GetSimple_3.0Beta_r323".
Oh, just found in the changelog for GS 3:
Quote:Conversion of all i18n calls to a new function
What does that mean? And how do I use it now?
Reply
#24
Texta Wrote:Oh, just found in the changelog for GS 3:
Quote:Conversion of all i18n calls to a new function

I think this is only how translations for the admin part are handled. It has nothing to do with the I18N plugin (which provides multiple languages for the public part).
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
#25
mvlcek Wrote:I think this is only how translations for the admin part are handled.
correct assumption.
- Chris
Thanks for using GetSimple! - Download

Please do not email me directly for help regarding GetSimple. Please post all your questions/problems in the forum!
Reply




Users browsing this thread: 1 Guest(s)