• Resolved korneelwever

    (@korneelwever)


    Hey,
    I’m working on a theme that uses a parent theme with an underlying framework.
    The theme and parent translate fine, thank you for the plugin on that part!

    But for some parts (the framework), the parent theme uses a textdomain located in a folder /languages:
    load_theme_textdomain( 'framework', rf_get_template_directory() . '/languages' );
    Found in the functions file of the parent theme, this resolves to /framework/languages in the parent theme.
    In that folder I see only a runway-framework.mo and .pot

    Is there a way can translate these, and add a language?
    If you need more info, let me know!
    Thanks!

    https://www.ads-software.com/plugins/loco-translate/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Tim W

    (@timwhitlock)

    The current 1.x version of the plugin only supports one text domain per theme.

    The only way around would be to create a dummy theme or dummy plugin that contains just the POT file for the framework. Then make sure you save all translations in the global languages directory so WordPress can find them before it looks in the theme’s framework directory.

    Thread Starter korneelwever

    (@korneelwever)

    Hey Tim,

    Thanks. I’ve created a plugin with just ‘framework’ and saved it’s translation in the global directory. I’ve named the plugin runway-framework and just copied the pot file. Loco sees it and I can translate, but it doesn’t show. So I think I need to do the second step you mentioned. Now, the parent theme has an existing translation, do you suggest to move that, or everything? Is there a quick way to do this?
    Thanks for your time, it’s very kind to provide free support ??

    Plugin Author Tim W

    (@timwhitlock)

    I’ve named the plugin runway-framework

    You said earlier the text domain is called just “framework” – did you declare this in your dummy plugin’s header comments?

    Ideally ensure you declare “Text Domain: framework” and call the POT file framework.pot

    Thread Starter korneelwever

    (@korneelwever)

    Yeah, I went with framework first, that didn’t work. Then I went with an exact copy of the pot file name. So clearly that didn’t work either, for reasons I understand now (the text domain is different and I didn’t declare it).

    Your last note helped, I forgot to declare the text domain in the plugin!

    Thanks, it looks like it’s working!

    So for any people finding this via the Google:
    I made a dummy plugin with just a readme.txt, a functions.php and the framework.pot file.
    I named it ‘framework’ and declared the text domain as such in functions.php:

    function my_plugin_load_plugin_textdomain() {
        load_plugin_textdomain( 'framework', FALSE, basename( dirname( __FILE__ ) ) . '/' );
    }
    add_action( 'plugins_loaded', 'my_plugin_load_plugin_textdomain' );

    Then I could use Loco Translate to add a translation which I added to the ‘global’ upon creation.
    I’m not 100% sure if loading the text domain this way is the absolute correct way of doing it, but that’s what I found and this works.
    Note: if your translations don’t show up, clear your server and browser cache!

    Plugin Author Tim W

    (@timwhitlock)

    Thanks for posting your results.

    I’m not 100% sure if loading the text domain this way is the absolute correct way of doing it

    WordPress has no real concept of a plugin’s translations or a theme’s translations and nothing to enforce they are unique. Text domains are just generic namespaces that anyone can use and load from anywhere they like. When files are found in the global location the third argument in your function call isn’t used at all. Hence why this hack works.

    For the record, version 2.0 of Loco Translate is in development and will hopefully make this problem go away.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘text domain referred to in code’ is closed to new replies.