Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Langage file for template ?
#1
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 ^^
Reply
#2
I would not go through an external plugin (eg I18N etc)
Reply
#3
I think that the exact same code for plugin translations will work for the theme. Check out the internationalisation page on the wiki.
“Don’t forget the important ˚ (not °) on the a,” says the Unicode lover.
Help us test a key change for the core! ¶ Problems with GetSimple? Be sure to enable debug mode!
Reply
#4
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.
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
#5
Ok,
Thank you both
I'll take a look above
Reply




Users browsing this thread: 1 Guest(s)