2 personman Jun 15, 2006 17:18

Thank you for the links. But this way of localization only works since version 1.8 and I'm using 0.9.2.
Is there a similar method for 0.9.2?
No, not that I know of.
Hardym, for private use with 0.9.x I think the best way is to add it to the global locales and use T_() as with the rest of the application.
by reading the document posted earlier, got a question.
Can i just have:
/my_plugin/locales/_global.php
which contains:
<?php
$trans[ 'fr_FR' ] = array(
'When I was writing this I was listening to:' => 'Something in french',
);
$trans[ 'de_DE' ] = array(
'When I was writing this I was listening to:' => 'Something in german',
);
?>
instead of having lots of directories and files....
And plugins would only need to translate a tiny amount so wouldn't hurt having it all in the one file...
Good idea. I've started implementing it and will commit it perhaps tomorrow.
Just got the latest cvs build and it still wasn't there. Heres how i've done it ( file; _plugin.class.php, line; somewhere in T_ function );
if( ! isset($trans[ $messages ] ) )
{ // Translations for current locale have not yet been loaded:
// echo 'LOADING', $plugins_path.strtolower( get_class($this) ).'/locales/'.$messages.'/_global.php';
@include_once $plugins_path.strtolower( $this->classname ).'/locales/'.$messages.'/_global.php';
@include_once $plugins_path.strtolower( $this->classname ).'/locales/_global.php';
And why was there get_class($this), instead of just $this->classname ..... ?
I've committed it.
I guess there was get_class() used, because if you would call Plugin::T_() out of the plugin constructor, it has no classname.
Plugin's constructors are deprecated now for 1.9, you should use PluginInit() instead (for b2evo 1.9).
Although this may not work due to the changes you made that plugins can be in any directory with the plugins folder, correct?
So it the plugin may not actually be in a folder structure like we plan...
They can.
Just for completion: the plugin's "locale dir" is the "locales" dir where the classfile is _or_ /plugins/[plugin_classname]/locales, if the plugin is a single file in /plugins/.
$plugins_path.strtolower( $this->classname ).'/locales/'
But isn't $plugis_path always referring to /blogs/plugins/ ?
Like with the recent updates, couldn't i have a plugin in the directory /blogs/plugins/my_plugin/anotherfolder/and_another/theplugin.plugin.php ?
So think about what you are quoting..
Yeh so i have the plugin;
/blogs/plugins/my_plugin/anotherfolder/and_another/theplugin.plugin.php
and locales folder here;
/blogs/plugins/my_plugin/anotherfolder/and_another/locales/
But that wouldn't work with the following code;
$plugins_path.strtolower( $this->classname ).'/locales/'
Would it?
No, it wouldn't.
So...... where's your quote from?
In CVS HEAD it's:
$locales_dir = dirname($this->classfile_path).'/';
if( $locales_dir == $plugins_path )
{
$locales_dir .= $this->classname.'/';
}
$locales_dir .= 'locales/';
From my post here;
http://forums.b2evolution.net//viewtopic.php?p=39515#39515
So i'm guessing if i do add plugins manually, like we discussed with Panels (if you remember), the Panels Plugin would also need to add their locales as well, unless the user wants to manually add them...
This should be helpful:
[url=http://manual.b2evolution.net/Localization#Plugins]Manual::Localization::Plugins[/url]
And [url=http://manual.b2evolution.net/Category:Plugins]here[/url] are some more manual pages about Plugins.