Recent Topics

1 Jun 15, 2006 10:55    

Hello,

Where should I put the localization of text variables of a plugin?
Should I put it in the main language file (locales/...) or should I create a new language file for this plugin? The plugin is not of general interest, so an integration into the next releases is imo unlikely.

Thanks
Hardy

3 Jun 16, 2006 10:10

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?

4 Jun 16, 2006 14:14

No, not that I know of.

5 Jun 17, 2006 02:37

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.

6 Jul 06, 2006 03:24

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

7 Jul 06, 2006 22:54

Good idea. I've started implementing it and will commit it perhaps tomorrow.

8 Jul 09, 2006 05:18

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 ..... ?

9 Jul 11, 2006 01:24

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).

10 Jul 11, 2006 07:50

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

11 Jul 11, 2006 19:13

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/.

12 Jul 11, 2006 19:16

$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 ?

13 Jul 11, 2006 19:19

So think about what you are quoting..

14 Jul 11, 2006 19:39

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?

15 Jul 11, 2006 19:49

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/';


Form is loading...