WordPress.org

Ready to get started?Download WordPress

Forums

Codestyling Localization
[resolved] Multiple textdomains in a single plugin (6 posts)

  1. GeertDD
    Member
    Posted 1 year ago #

    Is it possible for Codestyling Localization to pick up multiple textdomains used in a single plugin? We'd like to split the WooCommerce translation files up into a "woocommerce" and "woocommerce-admin" textdomain (see Github).

    Any pointers? Thanks.

    http://wordpress.org/extend/plugins/codestyling-localization/

  2. codestyling
    Member
    Plugin Author

    Posted 1 year ago #

    Yes, the plugin picks up each textdomain contained. It will also write the dedicated *.mo files to disk, if you switch the textdomain select box and press the generate button. The only textdomain not been written to disk in scope of a plugin/theme is the "default" or WordPress textdomain, because this is an issue within the translation context and the author must avoid that.
    Nevertheless my plugin will show a warning, that more than one textdomain is contained to show that this is either accidentally (most cases while copied foreign code blocks) or intentionally like in your illustrated case.

  3. GeertDD
    Member
    Posted 1 year ago #

    Okay, I see, multiple textdomains will all be picked up by the plugin, cool. If you have a look at the WooCommerce ticket at Github you'll see that the discussion now has moved on to the point where we'd keep working with a single textdomain. The only thing that would change is the mo-files that get loaded. In the admin an extra mo-file with admin-only translations would be loaded too. I guess that's no problem for Codestyling, the only question that remains then is to which file Codestyling will write its translations? Thanks.

  4. codestyling
    Member
    Plugin Author

    Posted 1 year ago #

    My plugin picks up each textdomain. Let's assume, that you are using 'woocommerce' and 'woocommerce-admin'. You will find both inside the drop down list of contained textdomains and will also face the warning for more than one textdomains.

    By selecting one of them, you will only see those strings, that are related to the given textdomain. All the strings will be hosted within one *.po file. But if you generate the *.mo file, it depends on what textdomain is currently selected.

    Generating the file for textdomain 'woocommerce' will result in writing a file like: woocommerce-de_DE.mo
    Generating the file for textdomain 'woocommerce-admin' will result in writing a file like: woocommerce-admin-de_DE.mo
    Both files only contains those strings related to the textdomain.

    If your plugin loads both textdomains, than you will get all translations where needed. So the admin one should be loaded only, if you are logged in and working within admin pages.

    Hint: My plugin uses the first found textdomain as the main one. The order of load call appearance in PHP code will determine the choise of plugins main textdomain.

  5. kruglikov
    Member
    Posted 1 year ago #

    What about multiple textdomains in one theme?
    As I see Codestyling plugin generates only one de_DE.mo file for my theme.
    And this file contains translation with textdomain selected before click 'generate mo-file'..
    Is that right?

  6. Thibaud
    Member
    Posted 1 year ago #

    Hi, same problem

    only one .mo file created, for exemple fr_FR.mo, depending on what textdomain is currently selected. No compilation nor split.

    Is it different with themes ?

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.