Reputation: 2561
I have a Plone site with internationalized content, using Archetypes and LinguaPlone.
Some of my objects (including folders) are language neutral, others are not. For generation of menus and navigation breadcrumbs, I'd like a method which
Title()
, if the Language()
is non-empty (because under this condition the title
attribute is supposed to match the language), andTitle()
otherwise (because the object is used for multiple languages, and I have a small set of affected strings).I couldn't find any *title*
method in the Products.LinguaPlone
package; pretty_title_or_id
is apparently language-agnostic.
Is there really no such method yet?
(Products.LinguaPlone 4.1.8, Products.CMFPlone 4.3.3, Products.ATContentTypes 2.1.14)
Edit: The affected objects are a limited number of folders (near the site root) whose titles very rarely change; most others have a non-empty Language
(which will cause their Title
not to be translated) or are non-folders (and won't have a known translation, I admit, but in those cases the original title would be used). I could imagine to patch pretty_title_or_id
accordingly, and I wonder about reasons not to do so.
Upvotes: 1
Views: 91
Reputation: 156
When using LinguaPlone you create different content foe each language, so having a method that returns different language values doesn't make much sense...
If you want to do that with language independent content, you will need to patch objects' Title method and add your custom code there... Anyway this will have an impact in the catalog because only the default language content will be catalogged both for the index content and metadata, and will return strange results... So this is discouraged.
Upvotes: 0
Reputation: 2561
I'll answer myself: It seems there is no such method because the standard set of metadata fields is not sufficient to support it.
For a small fixed set of languages, it might be a good solution to use title_<lang>
metadata fields.
Upvotes: 0
Reputation: 7727
I don't think that's going to work, because navigation menus will look at the index and metadata only, and there's definitely only one Title
column in there, and you definitely don't want to not use the metadata there, for performance reasons.
You could, in theory, patch all templates you need (like the navigation portlet and the breadcrumb viewlet, but to be thorough, you'd need to patch everything that looks at Title
anywhere, ever) to pass all their strings through the translation layer (basically adding i18n:domain="..." i18n:translate=""
), and maintain your translations in a .mo
/.po
language file, but you'll have no way to change them at runtime. My gut feeling would be that that's patching over a conceptual problem with what lang-neutral items can and cannot do.
Upvotes: 1