• Resolved Hugo Callens

    (@prettiggeleerd)


    If I create a .po and .mo file for a plugin in the global languages/plugins/ folder, what happens to the corresponding files in the plugin’s own language directory?
    Can I create global files just to update *some* strings? Will the plugin’s .po and .mo files still take care of the rest?

    https://wordpress.org/plugins/loco-translate/

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

    (@timwhitlock)

    It’s not clear from your questions whether you intend to have more than one file of the same language. Are you creating custom versions of a language that’s already provided by the author?

    Thread Starter Hugo Callens

    (@prettiggeleerd)

    There is a default language file inside the plugin’s language folder. I would like to change some strings and thus created a custom file in the global languages folder. This file only changes a few strings.

    What will happen now? Will the plugin first use the global file and then fall back on the default plugin file to translate all strings not translated in the global file?

    Plugin Author Tim W

    (@timwhitlock)

    There is a default language file inside the plugin’s language folder.

    I’m unclear what you mean by a “default language file”. If you see something like default.po then the plugin is set up badly and you will probably run into further problems. If you want to know for sure, please post a link to download your plugin.

    I would like to change some strings and thus created a custom file in the global languages folder

    This is done by adding a new language in Loco Translate. Have you tried this yet? If it can understand your plugin it will create a localised version of the “default” file in the language you choose. It won’t overwrite any existing files.

    What will happen now?

    When WordPress looks for translations in your language it will first look wherever your plugin has asked it to. If it doesn’t find a matching file in your language it will only then look in the global languages directory.

    Will the plugin first use the global file and then fall back on the default plugin file

    I don’t know what your plugin will do, but my plugin isn’t involved in this process.

    Thread Starter Hugo Callens

    (@prettiggeleerd)

    OK, I see.
    The plugin indeed looked for its language file in its own folder. So I renamed these files in order to force the plugin to look in the global languages, and that works.
    Thank you very much for your help!

    Plugin Author Tim W

    (@timwhitlock)

    I’m glad this worked, but a better solution would be to use the override_load_textdomain filter if you’re able to.

    Thread Starter Hugo Callens

    (@prettiggeleerd)

    OK.
    How should I do that? Can I add this to my functions.php file?

    Plugin Author Tim W

    (@timwhitlock)

    You’ll have to write your own code for this. If you’re not sure, stick to your current methods.

    Thread Starter Hugo Callens

    (@prettiggeleerd)

    OK. Thanks again!

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Global language files vs plugin files’ is closed to new replies.