cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <ch...@christopherschultz.net>
Subject Re: Trouble switching locales with i18ntransformer
Date Thu, 11 Jan 2018 16:44:19 GMT
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Cédric,

On 1/9/18 2:39 PM, Cédric Damioli wrote:
> Just in case, did you try to hardcode the "es" value :
> 
> <map:transform type="i18n"> <map:parameter name="locale" value="es"
> /> </map:transform>

I just tried this, and it appears to work as expected: I get the
strings being loaded from bundle_es.xml.

That got me to reviewing a few things and I think this was a simple,
boneheaded syntax error on my part:

This:
        <map:transform type="i18n">
          <map:parameter name="locale" value="${i18n-locale}" />
        </map:transform>

should have been this:

        <map:transform type="i18n">
          <map:parameter name="locale" value="{global:i18n-locale}" />
        </map:transform>

Two changes:

1. Variable references do not have a $ prefix
2. Global variable references need the "global"

After fixing those two issues, I'm getting the expected text in the
expected language.

Apologies for the noise, and thanks for the help!

Thanks,
- -chris

> Le 09/01/2018 à 17:34, Christopher Schultz a écrit : All,
> 
> I have an I18NTranformer configured and <i18n> elements in my 
> stylesheets and everything is working for the default locale. But 
> changing locales doesn't seem to be working for me. I think I must
> be missing something.
> 
> I'm using Cocoon 2.1.11.
> 
> Here's what I have:
> 
> sitemap.xmap:
> 
> <map:components> <map:transformers> <map:transformer name="i18n"
> ...> <catalogues default="summary"> <catalogue id="common"
> location="/path/to/dir" /> <catalogue id="summary"
> location="/path/to/dir" /> </catalogues> </map:transformer> ... 
> </map:transformers>
> 
> <map:pipelines> <map:component-configurations> <global-variables> 
> <i18n-locale>en</i18n-locale> ... </global-variables> 
> </map:component-configurations>
> 
> <map:pipeline> <map:match ...> ... <map:transform type="i18n"> 
> <map:parameter name="locale" value="${i18n-locale}" /> 
> </map:transform> ... </map:match> </map:pipeline> 
> </map:components>
> 
> I have 3 files in /path/to/files:
> 
> common.xml     [xml:lang="en"] summary.xml    [xml:lang="en"] 
> summary_es.xml [xml:lang="es"]
> 
> This works as expected with <i18n-locale>en</i18n-locale> is set
> in the global-variables section.
> 
> I was expecting that changing <i18n-locale> to:
> 
> <i18n-locale>es</i18n-locale>
> 
> And then restarting Cocoon would end up using the text from my 
> summary_es.xml file, but it's still showing the English text from 
> summary.xml.
> 
> Replacing summary.xml with summary_es.xml works of course (i.e.
> the text from summary_es.xml is now showing in my rendered pages).
> 
> The client (browser) is advertising a preference for lang=en, but
> that shouldn't matter because I'm invoking the i18n transform
> specifically with locale="en", right? I even changed by browser's
> preferred language from English to Spanish and nothing changed.
> 
> I'd prefer to be able to change the locale by setting the 
> <i18n-locale> global variable and not doing anything else. What am
> I missing, here?
> 
> -chris
>> 
>> ---------------------------------------------------------------------
>>
>> 
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>> For additional commands, e-mail: users-help@cocoon.apache.org
>> 
> 
-----BEGIN PGP SIGNATURE-----
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQJRBAEBCAA7FiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAlpXlGIdHGNocmlzQGNo
cmlzdG9waGVyc2NodWx0ei5uZXQACgkQHPApP6U8pFiB0BAAkrdBkLQc4zy+D0Db
dRDpB6Tt2umhRR5T6fidWhWsY661IEV9GNWl1WdbYGW2OuozVwik8nOJBsFvmbTa
y+eejwWjzxRPqjwM+Lon9/6LVWgOWkHRTXrqwyxRD/6XfiXq73G5lc1e2xeFZICA
c3hmgHS98Ett1iX+pmMR+EDlW73dRR7SPFDk477v69E5JG4tnUamArlzLBURl5yA
OWkmY73wdLD2DQksb2ldHvTVM93b4K9PAz+7Y0Ch2zRBrIGzXsBzJ6YWHysEsdr0
IQNfUGwrj7BV8QmNwJx+rfSnJ5OSfaVM/+K3MAhyu8OPA1LouEos3L8D7KZnUpY5
mqN1/2XH8SotRsYrtnLF5dlongSGDtP+h/4PXyPevaBaPSQBlMLnET8COps3rR0E
lo4w6++Wtguv03rgt8KTegGtPq+RKOwvS12DKjx8ZMeEJipOYe1P/BwP90Xeq6J9
4ZqAqRIdGJd5SfVZfmnO+5Xa0X2q3spayHpVMnR2qHXsUEltDqvXdzuXUU2xTtln
FP6pC1c47lmWXSrwwZE8CXYfPpr2wvSdXFAlQ/a053kEi0QgPiO/pHU331cThBqE
pmxKtaj1xX1jIbKWfBu/0Y5Mgg1AJPbD5SxAWYweWNQ59qsXl986xnzuF83cUQJA
heZprqscW2yAz45/G8uRJkSwY6o=
=NJLR
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message