Archived

This topic is now archived and is closed to further replies.

  • 0

Simple translation patch for Pagelines


Question

Posted · Report post

Hi,

 

I have a little suggestion for developers. I want to translate PL menu in admin panel, but it is not so simple. Adding i18n for ui_key function in library.functions.php like that:

 

function ui_key($key){

-    return ucwords( str_replace( '_', ' ', str_replace( 'pl_', ' ', $key) ) );
+    if($key[0]=='_')
+        $key=substr($key,1);
+    return __(ucwords( str_replace( '_', ' ', str_replace( 'pl_', ' ', $key) ) ),'pagelines');
}

Could be much useful.

 

Share this post


Link to post
Share on other sites

7 answers to this question

Posted · Report post

If you test this and it works, I dont mind adding it to core.

Share this post


Link to post
Share on other sites

Posted · Report post

I made other plugin to generate items for gettext scanner, but idea with filters is much better :)

Adding it to core could be great.

 

Thanks.

Share this post


Link to post
Share on other sites

Posted · Report post

Hi,

 

Not sure why you would want to translate the PageLines settings name, as its our brandname. Its the same for brands like Coke Cola, the branding isn't translated, it remains the same throughout most countries.

Share this post


Link to post
Share on other sites

Posted · Report post

I don't want to translate "Pagelines" or anything related with your brand. Just menu items like "Site Options" or "Drag & Drop" could be translated for better understanding, especially in European languages :)

Share this post


Link to post
Share on other sites

Posted · Report post

As far as I am aware, it is already possible to translate the backend options, see our translation center - http://www.pagelines.com/translate/projects/pagelines-framework/nl/full?filters%5Bterm%5D&filters%5Buser_login%5D&filters%5Bstatus%5D=current_or_waiting_or_fuzzy_or_untranslated&sort%5Bby%5D=original&sort%5Bhow%5D=desc&sorts=Sort&page=14

The Dutch full translation has store translation to Winkel, which I assume is a correct translation.

Share this post


Link to post
Share on other sites

Posted · Report post

I've tested Dutch translation, and all tabs names in admin are still in english. The only way I know is add __() method to ui_key, as i wrote. Of course i can do this manually, but integrating it with core could be helpful thing :)

Share this post


Link to post
Share on other sites

Posted · Report post

No sorry that simply wont work.

 

The translation script scans the file for translation strings, it is NEVER actually executed, so:

 

__( 'hello', 'domain' );

would produce:

msgid "hello"
msgstr ""

 

__(ucwords( str_replace( '_', ' ', str_replace( 'pl_', ' ', $key) ) ),'pagelines');

would produce:

msgid ""
msgstr ""

 

So pointless.

 

A better idea would be:

 

function ui_key($key){


    $word = ucwords( str_replace( '_', ' ', str_replace( 'pl_', ' ', $key) ) );
    return apply_filters( 'pl_ui_key', $word, $key );
}
 
Now you can use a filter to do your translation.

Share this post


Link to post
Share on other sites