0

I'm trying to translate my plugin using poedit. I have following code in main plugin file:

<?php

    /*
    Plugin Name: FixFormData
    Description: If you want to autocomplete a form with existing data, this plugin is for you.
    Version: 1.1
    Author: Stijn Aerts
    Text Domain: ffd
    Author URI: http://stijnaerts.be
    License: GPL2
    */

require( plugin_dir_path( __FILE__ ) . 'menu.php');
require_once( plugin_dir_path( __FILE__ ) . 'getuser.php');

add_action( 'wp_enqueue_scripts', 'ffd_load_scripts');

function ffd_load_scripts()
{
    load_plugin_textdomain('ffd', false, dirname(plugin_basename(__FILE__)));
}

In menu.php is the string I'm trying to translate:

public function page_init()
    {        
        register_setting(
            'fixformdata_group', // Option group
            'fixformdata_options', // Option name
            array( $this, 'sanitize' ) // Sanitize
        );

        add_settings_section(
            'setting_section_id', // ID
            'FixFormData options', // Title
            array( $this, 'print_section_info' ), // Callback
            'my-setting-admin' // Page
        );  

        add_settings_field(
            'tablename', 
            __('Table name', 'ffd'), 
            array( $this, 'title_callback' ), 
            'my-setting-admin', 
            'setting_section_id'
        );
}

Where the string I try to translate is:

__('Table name', 'ffd'), 

However when I use poedit to create a catalogue, this fails, he says he can't find any strings to translate.

What am I doing wrong?

stijn.aerts
  • 6,026
  • 5
  • 30
  • 46

1 Answers1

1

In absence of any details about the "use Poedit to create a catalog" part, let me try a wild guess:

You probably didn't add __ to the keywords list, did you? (It isn't in xgettext's list of PHP defaults, because, well, it isn't a PHP default, so you have to add it.)

Václav Slavík
  • 6,445
  • 2
  • 28
  • 25
  • I added it to the keywords, that isnt the problem, the error that poedit is giving is that it cant find any strings. – stijn.aerts Sep 10 '14 at 13:40
  • Then it's probably because it can't find any strings. And that can only be because you didn't *point* it to any, so *something* in your configuration is wrong, be it keywords or paths. Again, the information you provided is not nearly enough to identify what you're doing wrong. You only tell half the story (the code) and it's the half that seems fine. You need to provide more information about the extraction part. – Václav Slavík Sep 10 '14 at 17:38
  • I just used this tutorial: http://weblogtoolscollection.com/archives/2007/08/27/localizing-a-wordpress-plugin-using-poedit/ with the same settings – stijn.aerts Sep 10 '14 at 18:14
  • If everything was with the same settings, it would probably work... Something is broken somewhere, but there's no way to tell what if you won't show what you did. If we can't see exactly what you did (all of it), we can't see what's wrong with it either. You really do need to expand on that "use Poedit to create a catalog" part a lot. Without that, the only thing I can suggest is to try Poedit's one-click WP support and be done with it. – Václav Slavík Sep 11 '14 at 04:13