GetSimple Support Forum

Full Version: Langage file for template ?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi all !

The create-a-thon is nearly finish and I've coded a new template but I want to make it as best as possible.

I've created a plugin for my template. While I configure it through the admin panel, language files work perfectly.
This plugin is displaying (or not) some information in the template like a sidebar and other things.

For example the sidebar is in template directory and called sidebar.php. I use some word like "Contact Us" directly in html. I added every translatable word in my plugin language file (in plugin/template-name/lang/fr-FR.php).
I don't know how to have the good translation in this component and in the template.

Is it possible ?

(i try my best to have a good english)

Thanks for your help
Sorry for my weird question ^^
I would not go through an external plugin (eg I18N etc)
I think that the exact same code for plugin translations will work for the theme. Check out the internationalisation page on the wiki.
didou038 Wrote:Hi all !
I've created a plugin for my template. While I configure it through the admin panel, language files work perfectly.
This plugin is displaying (or not) some information in the template like a sidebar and other things.

For example the sidebar is in template directory and called sidebar.php. I use some word like "Contact Us" directly in html. I added every translatable word in my plugin language file (in plugin/template-name/lang/fr-FR.php).
I don't know how to have the good translation in this component and in the template.

Since GetSimple 3.0 no language is set for the frontend (because of the multiuser capabilities).

The best way would be
  • to provide a language selection in your theme's administration
  • add the following code to your plugin in the index-pretemplate hook (make sure you don't call i18n_merge before):
Code:
if (function_exists('i18n_init')) { // I18N compatibility - you would need two-letter language files
  i18n_init();
  i18n_load_texts('mythemeplugin');
} else {
  global $LANG;
  $mythemesettings = ...; // read your theme plugin's settings
  $frontendlanguage = ...; // get language from settings
  $LANG = $frontendlanguage; // it's now available for all plugins
  i18n_merge('mythemeplugin'); // or i18n_merge('mythemeplugin',substr($LANG,0,2)); for two-letter language files
}
You could hide the language setting in your administration, if the I18N plugin is installed.
Ok,
Thank you both
I'll take a look above