Modifying status messages of a third party package

We're using plone.app.iterate for a project and the client wants to change the wording of some of the plone status messages that come from the browser views. Am I going to have to override the entire view with a browser layer just to change this message or is there a better way to do it? I've never used any of the translation service features in Plone (anglophone privilege) but maybe there's a way to use that - or maybe that's a bad idea. Thoughts?

Yes, you can do this with translations.

We override them this way as well.

All of plone's status messages are translatable(or should be).

One thing you might have to do is make sure your product's translations are loaded before any other for them to stick. To do this, you need to add zcml = my.product in your buildout config.

Use diazo.

no way, José :wink:

do as @vangheem suggests and @mauritsvanrees explains in his classic blog post:

http://maurits.vanrees.org/weblog/archive/2010/10/i18n-plone-4#overriding-translations

2 Likes

I did what @vangheem suggested and indeed that blog post was my guide. It worked exactly as expected once, once I figured out how to get the .mo files to compile. My only concern is that it is buildout specific instead of site specific and we tend to put a lot of sites on shared buildouts, but I can work around that.

We have used diazo for many projects but I don't see a reason to use it here. This site doesn't need a complete reskin so it seems like overkill to use diazo to handle this.

You don't need to do a complete redskin anymore with the new content to content diazo transforms. We use it for simple changes to things like login forms etc.

We have also used translations before to make customer specific customisations to language but its not really possible to isolate it to a specific site in a mutlisite setup. It would be very nice if this was possible, esp in a theme or another uploadable zip file.

create a policy package per site with your custom translations.

Can you explain that, or link to a reference? Is there a GenericSetup step or something?

in your case is just a package with a configure.zcml file registering a locales folder with your custom translations; this package has to be the first one Zope will read to override the other translations.

Right, but isn't that going to affect every site on that buildout? I can't say only do this translation if the foo.bar package is installed on this site?

It is -- with the stock translation machinery.

Translation uses the "ZCA" ("Zope Component Architecture") -- likely a utility. If you need something special, you could register your own component to do the translations.

yes, you're right; follow @dieter's advice.

You can put a condition when loading the zcml, the same idea that plone.app.locales: https://github.com/collective/plone.app.locales/blob/22e2c7ef2b7df5ebdc5ea6c5baeb67fdfee8de79/plone/app/locales/configure.zcml#L9

More info about conditions in zcml: http://docs.plone.org/develop/addons/components/zcml.html#conditionally-run-zcml

For the order in which translation files are loaded, see my i18n talk from the Arnhem conference 2012: