Overriding plone.app.locales

Hello there,

What is the canonical way (if there is any) of overriding some entries for translations in plone.app.locales?

I have a policy package, with a locales folder, and I tried to add an updated plonelocales.po there, but it seems the version on plone.app.locales always wins.

Ensure your package is loaded in zcml before plone.app.locales:

  1. in your configure.zcml load your policies locales as first: <i18n:registerTranslations directory="locales" />
  2. in buildout.cfg instance eggs and esp. in zcml section your package is the only or at least first one (esp. no Plone/Products.CMFPlone)
  3. try to avoid z3c.autoinlcude features
1 Like

See alternative instructions here:

You can add a locales folder in your buildout folder
There you place po files with same name as the file you want overwrite

1 Like

After doing that, you may need to add the following line in your configure.zcml just after the i18n:registerTranslations directive:

<include package="Products.CMFPlone" />

We were just biten by this.

3 Likes

To override the image type names in TinyMCE image insert dialog I

  • added a locales folder in buildout directory
  • added widgets.po with domain 'widgets' (copy of original widgets.po with msgids removed but the ones we need
  • <include package="Products.CMFPlone" />

No effect. As it is part of the TinyMCE stuff. Do I need to recompile resources? Or what do I miss?

Two things:

  • In a locales dir in buildout you still need the proper structure. I just saw a project with a file locales/plone.po which did not work. In your case for English it would need to be: locales/en/LC_MESSAGES/widgets.po.
  • Since this is TinyMCE, these translations may come from javascript. These translations are cached in the browser for a day, in localStorage. So open the developer tools of your browser, check if widgets-en is in localStorage and remove it.
1 Like

Removing widget-de from LocalStorage helped to see the modified translation. Thank you @maurits!

The suggestion from Maurits worked for me too - except for the content of the Favorites menu in the RelatedItemsFieldWidget:

"Current Content" and "Start Page" are in the plone domain (plone.po), but adding these to my overrides have no effect. (Other overrides in the same .po file does have an effect).
I assume they are also buried deep down in some compiled javascript - any tricks for these ones?

Best,
Sune

you can override this with your widgets directive, see mockup/src/pat/relateditems at master · plone/mockup · GitHub

If needed, you can use a function to return the correct values...

directives.widget(
    'related_image',
    RelatedItemsFieldWidget,
    pattern_options = {
        'recentlyUsed': True,
        'basePath'    : default_base_path,
        'mode'        : 'auto',
        'favorites'   : default_pattern_options,
        'folderTypes': ['Folder', 'LIF', 'LRF'],
        'selectableTypes' : ['Image'],
    }
)

Great! I will try it out. Thank you @mtrebron