• Salvatore Noschese

    (@salvatorenoschese)


    Hi, I’m developing a plugin and using Poedit for translation.

    I tried using some language strings that are already present in WordPress core, but even without specifying a text domain (or when using the default), these strings are still being imported into Poedit.

    Is this the correct behavior, or should I always specify a text domain for core strings in my plugin? Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hello @salvatorenoschese ,

    I think you are using this way !
    _e( 'Administration Email Address' );
    _e( 'Anyone can register' );

    So when you use the same string in your plugin without a text domain, Poedit will treat it as belonging to your plugin and might add it to your translation file.

    To avoid this and to ensure that the string is recognized as part of WordPress core translations, you should specify the 'default' text domain when using core strings in your plugin like this

    _e( 'Anyone can register', 'default' );

    Moderator bcworkz

    (@bcworkz)

    Poedit isn’t sophisticated enough to distinguish from different text domains in plugin files. Expected behavior, though I wouldn’t say it’s “correct” behavior ?? The textdomain property is principally used for organizational purposes and to allow WP to load the correct translation files. Since core translations are always loaded, it doesn’t really matter which you specify, but for consistency I recommend specifying anyway.

    Consider carefully which core translations you use. It’s possible a core string could change in the future, requiring you to update your code accordingly. Some strings are less likely to change than others. I’d stick with the unlikely to change strings.

    Thread Starter Salvatore Noschese

    (@salvatorenoschese)

    ty for reply. I used just some classic strings like delete, apply, and similar.

    atm I just need to maintain this without see in Poedit. Yep, I can manually remove, but if exist a simplest way to import only string with my custom-textdomain, can be best.

    Thread Starter Salvatore Noschese

    (@salvatorenoschese)

    @kallyansin , Sorry, seen only not your message.

    in realty I tried both without any text-domain, and with default. But are still present in po files when I run “import from source”.

    Hey @salvatorenoschese ,

    That is the default behaviour when Poedit scans for all the translateable strings in the WordPress Codebase which includes both core and your custom plugin code.

    Here is my suggestion to import only your plugin’s string into Poedit.

    1. Use a Unique Text Domain: __('Hello World', 'custom-plugin');
    2. Modify the Source Code Settings: Open your project, Go to Catalog > Properties > Sources , here specify your plugin path. for example wp-content/plugins/test-plugin/, Replace test-plugin with your plugin name.
    3. In the same dialog box exclude wp-includes/ wp-core/ but again if you specify the exact plugin path as mentioned in step 2 this step can be skipped.
    4. Run import again and see if it works.

    Please try above mentioned solution. Let me know if you need any further help.

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.