Hi I was translating one of my plugins in “CodeStyling Localization”. when I update my plugin my translation erased. Is there anyway to find it ? And How can I backup my translation (I don’t want to waste my time next time :))
1 comment
Comments are closed.
You should move the po- and mo-file with the translation of your plugin outside your plugin’s directory. Whenever you update your plugin, your plugin files are replaced causing any file that is not part of the default plugin package to be deleted. (If you are translating your own plugin, you could as well add the translation files directly to your plugin repository.)
How to move custom translation files outside of the plugin’s directory? In your plugin code, add a method like this to the
init
hook:The code above first looks for a translation file in
WP_LANG_DIR
, to be found inwp-content/languages/
by default. Putting your custom translation files in there is safe for upgrades.Also, by using the the approriate hook and functions to load the translations for your plugin, you allow users to hook into the language loading process for your plugin, giving them much flexibility to load language file(s) from anywhere they want.
I’ve written a more in-depth article about this on my blog.