Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Wordpress is awesome, but there is something that is driving me crazy.

Whenever a plugin or a theme is updated, all files are deleted and replaced. So if I have custom code or a translation in one plugin, it will get lost!

I've seen some solutions suggesting to change the textdomain of the plugin to load language files from wp-content/languages, but if I write a custom function to load the *.po and *.mo from wp-content, directly in the plugin code, it will get overwritten too.

So I was wondering how I can update my plugins, without losing the translation or the custom code.

I ended up with WPML strings that do the job, by saving translation in DB, ( I'm not sure if is the way) but WPML is a very heavy plugin, and I will have to install it in all sites, which makes it difficult to maintain.

Is there any function to overwrite all textdomains of a plugin, so I can have all of the translations in wp-content/languages, without changing plugin code?

share|improve this question
    
As starting point, always backup the translations you do. Second, send them to the plugin/theme author, high probability of getting them included in the next releases. Related: [1] + [2] + [3]. –  brasofilo Feb 16 '13 at 21:52
    
custom translation. –  André Feb 17 '13 at 1:20
    
some plugins like woocommerce are enabled to read wp-content/languages/woocommerce/ mo and po files default so translations won't be overwiten. Also since 3.5 translation of themes by default from wp-content, but plugins not yet. core.trac.wordpress.org/ticket/18200#comment:43 –  André Feb 17 '13 at 6:58
    
Would the core of your Question be: "How to prevent themes/plugins that don't work with /wp-content/languages to load their language files and force them to load my own files" ? –  brasofilo Feb 17 '13 at 7:09
    
well done! sure it is –  André Feb 17 '13 at 8:39

1 Answer 1

Here is a patch for 3.5 to use this with plugins.
Use wp-content/languages/plugins/textdomain-pt_BR.po

Apply this via SSH with: patch -p1 < no_plugin_overwrite.patch
Hopefully its gonna be released in 3.6.

Ticket #18200 (new task (blessed))

Implement language packs for core, plugins, and themes.

share|improve this answer
    
Eu sabia! André com acento no é ;) - Great to know this is a core candidate, I like this string in the patch: 'Some of your language files need updating, Sit tight for a few more seconds while we update them as well.' –  brasofilo Feb 17 '13 at 10:04

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.