The following code translates
my_translateable_text
to the native language activated for the current page.
How does this works?
The following code translates
my_translateable_text
to the native language activated for the current page.
How does this works?
Right below it , on the same page:
Translation string substitution
I mean, Plone will translate everything if there's an entry in a .po? For example if a='my text' and I've an entry for 'my text' in a it.po file for the current language (for example mio testo
, then
<span tal:content="a"></span>
will output mio testo
if the language is it
? And this without any additional code?
Generally yes, MessageStrings are incredibly useful. @mauritsvanrees wrote some blog posts many years ago that are still my go-to documentation...
Edit: see Mikel's clarification below ... It does not work for plain text strings.
In a TAL template, you would use a stanza like:
<span i18n:translate="msg_greeting" i18n:domain="mypackage">Hello</span>
where in your mypackage's it .po
msgid "msg_greeting"
msgstr "Buongiorno"
Edit2, or
<span i18n:translate="" i18n:domain="mypackage" tal:content="here/my_greeting">Good Morning / Good Afternoon</span>
msgid "Good Morning"
msgstr "Buongiorno"
msgid "Good Afternoon"
msgstr "Buonasera"
You can set the default i18n:domain at the top of your template, right after its namespace definitions
No, it means that if a
is an instance of zope.i18nmessageid.message.Message
, it will be translated. It won't translate plain strings.