Current time: 05-24-2012, 06:05 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?

If you want to receive support by me, please send me a PM or use Jabber to let me know you're waiting for me.
Jabber: janmalte@ubuntu-jabber.de
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)
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

If you want to receive support by me, please send me a PM or use Jabber to let me know you're waiting for me.
Jabber: janmalte@ubuntu-jabber.de
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.
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.

Dennis Tsang :: MyBB Developer
Follow me on Twitter: @dennistt
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)

Contact Us | MyBB | Return to Top | Return to Content | Lite (Archive) Mode | RSS Syndication