Roundcube Community Forum

 

How to load custom translation / localization strings from plugin to main application

Started by Makc666, January 21, 2010, 09:26:14 AM

Previous topic - Next topic

Makc666

Story:

  • I have modified the login template:
./skins/my_theme/templates/login.html
  • I added there my own translated string:

  • Then I created the file:
/program/localization/ru_RU/extra.incwith code like:
<?php

$labels
['l_search'] = 'Search New Text';

?>

  • Then to the end of the file
/program/localization/ru_RU/labels.incI added the line:
include ('extra.inc');
  • All work OK.

What I want:

But I don't want to modify the file
/program/localization/ru_RU/labels.incevery time the new release comes out.

I want to move my custom translation string(s) to the plugin's system.

What I did:

I tried and created plugin like this one:

<?php

/** 
 * Extra Languages 
 */
class extra_languages extends rcube_plugin
{

  function 
init()
  {
    
$this->add_hook('startup', array($this'startup'));
    
$this->add_hook('authenticate', array($this'authenticate'));
    
$this->add_texts('localization'true);              
  }                                                      
                                                         
  function 
startup($labels)                              
  {                                                      
    
$labels['l_search'] = $this->gettext('l_search');        
    return ??????????;                                   
  }

  function 
authenticate($args)
  {
    
$labels['l_search'] = $this->gettext('l_search');
    return ???????;
  }

}
P.S.
Of course I have added the proper "localization" folder for this plugin.
In other words the code in this plugin
  function startup($labels)                              
  {                                                      
    print 
$this->gettext('l_search');
    exit;
  }
works when I enter the index.php page.

The question (problem):

I don't know how to return $this->gettext('l_search'); back to main application so it has been merged with global text strings (labels).

Is there any why to return from this plugin my custom translation strings?
...... ...... "А стукачков мы не любим!"

rosali

Check 'lang_sel' plugin bundled with MyRoundcube plugins (see signature). There you see a method how to merge localizations with the default localization.
Regards,
Rosali