Author Topic: How to load custom translation / localization strings from plugin to main application  (Read 3275 times)

Offline Makc666

  • Jr. Member
  • **
  • Posts: 23
    • http://makc666.com
Story:

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

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

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

?>

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


What I want:

But I don't want to modify the file
Code: [Select]
/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?
« Last Edit: January 12, 2012, 09:24:25 AM by Makc666 »
...... ...... "А стукачков мы не любим!"

Offline rosali

  • Hero Member
  • *****
  • Posts: 2,533
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
__________________
MyRoundcube Project (commercial)