• I have developed my own Italian translation and uploaded the .po .mo files but they get overwritten when a new version is issued. How to prevent that?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Ján Mikláš

    (@neosinner)

    Hi @flipgatt, whatever files you replace, update or modify in any way inside /wp-content/plugins/mailpoet/ will always get overwritten on plugin update.

    To prevent that, you’ll have to add the custom translations to some other folder and write a script (or MU plugin in wp-content/mu-plugins/) to load them, something like this (I haven’t try that, but should work in theory):

    <?php
    /**
    * Plugin Name: MailPoet custom Italian translation
    */

    add_filter(
    'load_textdomain_mofile',
    static function ($mofile, $domain) {
    if ($domain !== 'mailpoet' || basename($mofile) !== 'mailpoet-it_IT.mo') {
    return $mofile;
    }

    $custom = WP_CONTENT_DIR . '/languages/custom/mailpoet-it_IT.mo';

    return file_exists($custom) ? $custom : $mofile;
    },
    10,
    2
    );

    You can read more about loading custom translations in https://developer.wordpress.org/plugins/internationalization/how-to-internationalize-your-plugin/#plugins-on-wordpress-org and here is documentation for that function https://developer.wordpress.org/reference/hooks/load_textdomain_mofile/.

    Thread Starter flipgatt

    (@flipgatt)

    I have /public/languages/plugins

    as my installation is multi-site

    I place my own .po .mo there, but it is overwritten when there is an upgrade

    with woo commerce plugin this does not happen, files are not overwritten

    thanks

Viewing 2 replies - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.