[
https://issues.apache.org/jira/browse/WW-4742?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15883367#comment-15883367
]
Yasser Zamani edited comment on WW-4742 at 2/24/17 7:29 PM:
------------------------------------------------------------
[~mtsbarbosa], your application should not reach those lines normally because
those lines will execute only if Struts cannot resolve your key (i.e.
Obrigatório) to a value. If you want just a constant string (i.e. "Obrigatório
- not mapped word in any dictionary") there, then you do not need +<@s.text+
tag at all and if you need to resolve the "Obrigatório" to a string according
to user selected locale, then create a file named
<your_action_name>_<locale>.properties beside your action which returns that
ftl and *save it as ISO-8859-1* e.g.
{code:title=MyFtlAction.properties|borderStyle=solid}
Obrigatório=Required
{code}
{code:title=MyFtlAction_de.properties|borderStyle=solid}
Obrigatório=verplicht
{code}
then *save your message.ftl as UTF-8* as below
{code:title=message.ftl|borderStyle=solid}
...
<@s.text name="Obrigatório" />
...
{code}
{color:red}Currently Struts just pass a Locale to freemarker rather than any
encoding, so freemarker uses it's default (UTF-8) to read your ftl files.{color}
I will be working on it if Struts can also provide the encoding for underlying
freemarker, which will enable you to save ftl files as different encodings.
[~lukaszlenart], is it needed to working on? however, freemarker has some
locale-encoding mapping which simply can be enabled in Struts.
was (Author: yasser.zamani):
[~mtsbarbosa], your application should not reach those lines normally because
those lines will execute only if Struts cannot resolve your key (i.e.
Obrigatório) to a value. If you want just a constant string (i.e. "Obrigatório
- not mapped word in any dictionary") there, then you do not need +<@s.text+
tag at all and if you need to resolve the "Obrigatório" to a string according
to user selected locale, then create a file named
<your_action_name>_<locale>.properties beside your action which returns that
ftl and *save it as ISO-8859-1* e.g.
{code:title=MyFtlAction.properties|borderStyle=solid}
Obrigatório=Required
{code}
{code:title=MyFtlAction_de.properties|borderStyle=solid}
Obrigatório=verplicht
{code}
then *save your message.ftl as UTF-8* as below
{code:title=message.ftl|borderStyle=solid}
...
<@s.text name="Obrigatório" />
...
{code}
Currently Struts just pass a Locale to freemarker rather than any encoding, so
freemarker uses it's default (UTF-8) to read your ftl files.
I will be working on it if Struts can also provide the encoding for underlying
freemarker, which will enable you to save ftl files as different encodings.
[~lukaszlenart], is it needed to working on? however, freemarker has some
locale-encoding mapping which simply can be enabled in Struts.
> Problem with escape when the key from getText has no value
> ----------------------------------------------------------
>
> Key: WW-4742
> URL: https://issues.apache.org/jira/browse/WW-4742
> Project: Struts 2
> Issue Type: Bug
> Components: Core Tags
> Affects Versions: 2.5.8, 2.5.10
> Reporter: Mateus Carvalho
> Priority: Minor
> Fix For: 2.5.next
>
>
> When using an encoding like ISO-8859-1 and having the following situation:
> {code:title=message.ftl|borderStyle=solid}
> ...
> <@s.text name="Obrigatório - not mapped word in any dictionary" />
> ...
> {code}
> We have the following output after update 2.5.8:
> {code}
> Obrigat\u00F3rio - not mapped word in any dictionary
> {code}
> After careful look at the source code and issues from the 2.5.8 I found the
> problem happens just in one added line on WW-4712, the following part of the
> code:
> {code:title=TextProviderHelper.java|borderStyle=solid}
> ...
> public static String getText(String key, String defaultMessage, List<Object>
> args, ValueStack stack, boolean searchStack) {
> ...
> //This escape causes the problem
> msg = StringEscapeUtils.escapeEcmaScript(msg);
> ...
> }
> ...
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)