2016-07-01, 05:26:37
(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.
- 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
...