[wp-hackers] Plugin Language Translation

Andy Staines andy at yellowswordfish.com
Sun Mar 25 16:23:59 GMT 2007


Alex Günsche wrote:
> On Sun, 2007-03-25 at 13:41 +0100, Andy Staines wrote:
>   
>>>> Absolutely. Thanks for taking a look. I have zipped them up and they are at:
>>>> Download mo-po <http://www.yellowswordfish/downloads/French-mo-po-files.zip>
>>>>         
>
> Ok, the problem is, as far as I see, that you do not provide the
> textdomain to use to the WP function __(). For example, you have the
> code
>
> __("Forum Locked")
>
> but when you use the textdomain "simple-forum", it should read
>
> __("Forum Locked", "simple-forum")
>
> You mentioned that some words actually were translated, I assume they
> are words that are contained in the global language file (e.g. "Posts").
>
> By the way, in your beta, the filename is simple-forum-FR_fr.mo, while
> it should read simple-forum-fr_FR.mo as this is the correct and usual
> locale token. And, you should use the API hook "init" for loading the
> textdomain, because this ensures that multilinguality plugins such as
> Polyglot will choose the correct language.
>
> HTH
>
> Regards,
> Alex
>
>   
Sorry Alex, can I double-check what I have done here because I'm still 
not getting anything. In fact, in the admin side I'm not even getting 
the 'cancels', 'edits' etc., any more!

(Renamed and rebuilt the mo by the way - shorter name, less bytes).

(1) My config.php is set to: 'WPLANG', 'fr_FR' - and I am getting WP in 
French.

(2) I have put the load textdomain into an 'init' action as you advised:

    add_action('init', 'sf_localisation');

    function sf_localisation()
    {
        load_plugin_textdomain('sforum',
    ABSPATH.'wp-content/plugins/simple-forum/languages/sforum-'.get_locale().'.mo');
    //    load_plugin_textdomain('sforum',
    ABSPATH.'/wp-content/plugins/simple-forum/languages/');
    }

I've seen this done with both formats above in other plugins (although 
never, interestingly, in  an 'init') so I have tried with both.

(3) I have changed the __( and _e( calls to the format __("Locked", 
"sforum")

(4) My newly compiled .mo file is now named 'sforum-fr_FR.mo'

.... and... nothing?

Can you spot what I may have missed please?

regards
Andy





More information about the wp-hackers mailing list