Saving new language/translation file on plugin update

Most of  our users are frustrated with the removal of the language files inside the plugin’s language folder on plugin update. This is default behavior on update of a plugin since while updating a plugin, all the older files in the plugin are replaced by the new files.

Describing the issue:

Suppose you use our plugin which comes with default languages like this:

Then you added your own language file for Czech language named: video-conferencing-with-zoom-api-cs_CZ.po

By default, this file will be removed on the next update of the plugin.

How to solve this?

The basic solution to this is to change the location of the translation files. We can solve this in two ways:

Automatic way:

To create a new file location for new translations (in our example we are creating new translation for Czech) in the context of Loco Translate plugin, do the following:

  1. Select the plugin you want to translate from Loco Translate -> Plugins.
  2. After that, click New language on the top( Notice in the image below, Czech is not listed yet ):


  3. Then select the language you want ( in our case Czech ) and then select the location for the file i.e. System: languages/plugins/video-conferencing-with-zoom-api-cs_CZ.po


  4. Then click Start translating
    After finishing, the new translation Czech will be listed in the previous listing like this:


  5. This will create a folder inside wp-content like before in this way:

Manually:

To solve this issue, create a folder( if not already exists ) named: ‘languages‘ inside your wp-content folder.

Then inside it, create the theme/plugin specific folder for the respective theme/plugin. In our case we will create a folder named: plugins

After that we put all our language files inside plugins folder like this:

Then from the translation plugin you are using, select this specific file from the setting. In our example we are using Loco Translate plugin and we can choose this file i.e ( languages/plugins/video-conferencing-with-zoom-api-{locale}.po ) from the setting like this:

Voila!!! You are good to go. From now on your language translation files will be safe on next plugin update.

Leave a Reply

Your email address will not be published.