Thread Rating:
  • 3 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Support for multilanguage sites, Internationalization (I18N)
(2016-06-27, 22:38:29)barknezz Wrote: Hello mvlcek!
This plug-in is really life saver but I was failed to add multi-language php tags to components as you mentioned on this page: http://get-simple.info/wiki/plugins:i18n...uages_i18n

The steps I followed:
1- Added new languages to admin/lang such as de_DE, ru_RU
2- Added <?php i18n("WHOWERARE"); ?> to my footer component.
3- Added "WHOWEARE" => "Who We Are in spesific language?" to all language files that I have.

English version works like charm, however when I set my language to another language on website (not on admin panel), it keep showing me only English version, not other language versions.

I don't really know if I do something wrong. How can I fix this? I will create detailed product pages in 20 different languages so I do REALLY need to know how to fix this :| Thank you very much.

Ok, here's the How to use language files with the I18N plugin:
  • create a directory /plugins/texts/lang (a dummy plugin for your site's texts)
  • add language files to this directory, with the two-letter language codes used by the I18N plugin, e.g. de.php
Code:
<?php
$i18n = array(
  'TEXT1' => "Deutscher Text"
);
  • add the following code to the top of your template file (try to load language files according to the user's language preference, the default language as defined on the I18N Pages view in the administration and English as last fallback):
Code:
<?php
$preferedLanguages = return_i18n_languages();
foreach ($preferedLanguages as $l) {
    i18n_merge('texts', $l);
}
i18n_merge('texts', return_i18n_default_language());
i18n_merge('texts', 'en');
?>
  • add <?php i18n('texts/TEXT1'); ?> whereever you want a localized text ('texts/', because your keys are in the texts plugin, here with key 'TEXT1') in your template.
If you have pages that are the same in all languages except some terms, you can use placeholders in the default language page instead of creating pages for all languages:
  • install the DynPages plugin
  • create a component text with the following content:
Code:
<?php global $args; i18n('texts/'.$args[0]); ?>
  • use {% text TEXT1 %} (here with key 'TEXT1'), whereever you need in your default language pages, e.g. the following content for a product specification:
Code:
Notebook 1503X:
{% text processor %}: Core I5
{% text speed %}: 2.5MHz
{% text size %}: 30cm x 20cm x 2cm
...
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply


Messages In This Thread
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
RE: Support for multilanguage sites, Internationalization (I18N) - by mvlcek - 2016-07-01, 05:26:37
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: 5 Guest(s)