Current time: 01-09-2009, 01:11 AM Hello There, Guest! (LoginRegister)


Post Reply 
Language support for plugin settings
08-16-2008, 12:05 PM (This post was last modified: 08-16-2008 12:14 PM by Jan.)
Post: #1
Language support for plugin settings
Hello,

is there a possibility so provide language support for own plugins?
Something like this should work:
PHP Code:
$lang->load("plugins/bdnames");
    
$bdnames_setting_1 = array(
        
"sid"            => "NULL",
        
"name"            => "bdnames_use_advanced",
        
"title"            => $lang->bdnames_use_advanced,
        
"description"    => $lang->bdnames_use_advanced_description,
        
"optionscode"    => "yesno",
        
"value"            => "1",
        
"disporder"        => "1",
        
"gid"            => intval($gid),
    ); 
But this sets the language at the activation of my plugin. How can i make it depending on the users language?
Could something like this work:
PHP Code:
    $bdnames_setting_1 = array(
        
"sid"            => "NULL",
        
"name"            => "bdnames_use_advanced",
        
"title"            => '$lang->bdnames_use_advanced',
        
"description"    => '$lang->bdnames_use_advanced_description',
        
"optionscode"    => "yesno",
        
"value"            => "1",
        
"disporder"        => "1",
        
"gid"            => intval($gid),
    ); 
I think not realy, because how does the mybb knows which file it should load?

Support for Plugins only at www.mybboard.de or www.mybbcoder.info

[jabber]janmalte@ubuntu-jabber.de[/jabber]
Visit this user's website Find all posts by this user
Quote this message in a reply
08-16-2008, 01:21 PM (This post was last modified: 08-16-2008 01:23 PM by Yumi.)
Post: #2
RE: Language support for plugin settings
You could do something like that:
PHP Code:
function my_activate()
{
global 
$lang;
$lang->load('my');
$new_setting = array(
... => 
$lang->something
);



Or you can use the fact that MyBB searches for language variables (setting group langvars should be named setting_group_{$name} and setting titles are named setting_{$name} whilst descriptions are setting_{$name}_desc)

Who is Yumi?


It's still the KFC crazed person who can't spell names properly with annoying AlTeRnAtInG CaPiTaLs in the NaMe
Visit this user's website Find all posts by this user
Quote this message in a reply
08-16-2008, 02:53 PM
Post: #3
RE: Language support for plugin settings
Yes, this is what i did.
But then the placeholder for the language will be replaced on activation.
All admins will see the settings in the same language and not in their own language. But this is what i wanna have

Support for Plugins only at www.mybboard.de or www.mybbcoder.info

[jabber]janmalte@ubuntu-jabber.de[/jabber]
Visit this user's website Find all posts by this user
Quote this message in a reply
08-17-2008, 07:01 AM
Post: #4
RE: Language support for plugin settings
Then use the second solution I gave...
You could add a plugin hook to load the necessary langvars for the settings page if you want to have it in an external .lang.php file.

Who is Yumi?


It's still the KFC crazed person who can't spell names properly with annoying AlTeRnAtInG CaPiTaLs in the NaMe
Visit this user's website Find all posts by this user
Quote this message in a reply
08-19-2008, 11:52 PM
Post: #5
RE: Language support for plugin settings
The settings that plugins add should be translatable in the same way that default settings are translated.
PHP Code:
$l['setting_group_<name>'] = "Setting group name";
$l['setting_group_<name>_desc'] = "Setting group description";

$l['setting_<name>'] = "Name";
$l['setting_<name>_desc'] = "Description"
<name> is replaced with the codename of your setting/group.

As Zinga said, you can have a plugin hook to load your plugin's language file in the settings manager.

[Image: sig.php?mybb]
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump: