GetSimple Support Forum
Langage file for template ? - Printable Version

+- GetSimple Support Forum (http://get-simple.info/forums)
+-- Forum: GetSimple (http://get-simple.info/forums/forumdisplay.php?fid=3)
+--- Forum: Developer Discussions (http://get-simple.info/forums/forumdisplay.php?fid=8)
+--- Thread: Langage file for template ? (/showthread.php?tid=3002)



Langage file for template ? - didou038 - 2012-03-28

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 ^^


Langage file for template ? - didou038 - 2012-03-28

I would not go through an external plugin (eg I18N etc)


Langage file for template ? - Zegnåt - 2012-03-28

I think that the exact same code for plugin translations will work for the theme. Check out the internationalisation page on the wiki.


Langage file for template ? - mvlcek - 2012-03-28

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.


Langage file for template ? - didou038 - 2012-03-28

Ok,
Thank you both
I'll take a look above