struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Amine BADID <amineba...@yahoo.fr>
Subject Re: Problem with internationalisation of Struts2
Date Sun, 24 Aug 2014 11:42:29 GMT
Hi Lukasz.
Thank you.
I've found the problem.
It was about an accentuated word. I've forget to add a number to the unicode word like '\u00e9'.
The class TextProviderHelper do not give the good message !
Because it lacks only a letter in the document global_fr.properties, TextProviderHelper do
not see it !
I hope in the futurthat Struts team will modify the message.

Here is the source code of this class !!!! :
/* * $Id$ * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor
license agreements.  See the NOTICE file * distributed with this work for additional information
* regarding copyright ownership.  The ASF licenses this file * to you under the Apache License,
Version 2.0 (the * "License"); you may not use this file except in compliance * with the License.
 You may obtain a copy of the License at * *  http://www.apache.org/licenses/LICENSE-2.0 *
* Unless required by applicable law or agreed to in writing, * software distributed under
the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied.  See the License for the * specific language governing
permissions and limitations * under the License. */ package org.apache.struts2.util; import
com.opensymphony.xwork2.util.ValueStack;
import com.opensymphony.xwork2.util.logging.Logger;
import com.opensymphony.xwork2.util.logging.LoggerFactory;
import com.opensymphony.xwork2.TextProvider; import java.util.Iterator;
import java.util.List;
import java.util.LinkedList;
import java.util.Collections; /** * Helper methods to access text from TextProviders */
public class TextProviderHelper { private static final Logger LOG = LoggerFactory.getLogger(TextProviderHelper.class);
/** * <p>Get a message from the first TextProvider encountered in the stack. * If the
first TextProvider doesn't provide the message the default message is returned.</p>
* The stack is searched if if no TextProvider is found, or the message is not found. * @param
key             the message key in the resource bundle * @param defaultMessage  the message
to return if not found (evaluated for OGNL) * @param args            an array args to be used
in a {@link java.text.MessageFormat} message * @param stack           the value stack to use
for finding the text * * @return the message if found, otherwise the defaultMessage */ public
static String getText(String key, String defaultMessage, List<Object> args, ValueStack
stack) { return getText(key, defaultMessage, args, stack, true); } /** * <p>Get a message
from the first TextProvider
 encountered in the stack. * If the first TextProvider doesn't provide the message the default
message is returned.</p> * <p>The search for a TextProvider is iterative from
the root of the stack. * <p>This method was refactored from  {@link org.apache.struts2.components.Text}
to use a * consistent implementation across UIBean components.</p> * @param key    
        the message key in the resource bundle * @param defaultMessage  the message to return
if not found (evaluated for OGNL) * @param args            an array args to be used in a {@link
java.text.MessageFormat} message * @param stack           the value stack to use for finding
the text * @param searchStack     search stack for the key * * @return the message if found,
otherwise the defaultMessage */ public static String getText(String key, String defaultMessage,
List<Object> args, ValueStack stack, boolean searchStack) { String msg = null; TextProvider
tp = null; for (Iterator iterator =
 stack.getRoot().iterator(); iterator.hasNext();) { Object o = iterator.next(); if (o instanceof
TextProvider) { tp = (TextProvider) o; msg = tp.getText(key, null, args, stack); break; }
} if (msg == null) { // evaluate the defaultMesage as an OGNL expression if (searchStack)
msg = stack.findString(defaultMessage); if (msg == null) { // use the defaultMessage literal
value msg = defaultMessage; } if (LOG.isWarnEnabled()) { if (tp != null) { LOG.warn("The first
TextProvider in the ValueStack ("+tp.getClass().getName()+") could not locate the message
resource with key '"+key+"'"); } else { LOG.warn("Could not locate the message resource '"+key+"'
as there is no TextProvider in the ValueStack."); } if (msg.equals(defaultMessage)) { LOG.warn("The
default value expression '"+defaultMessage+"' was evaluated and did not match a property.
 The literal value '"+defaultMessage+"' will be used."); } else { LOG.warn("The default value
expression '"+defaultMessage+"'
 evaluated to '"+msg+"'"); } } } return msg; } /** * <p>Get a message from the first
TextProvider encountered in the stack. * If the first TextProvider doesn't provide the message
the default message is returned.</p> * <p>The search for a TextProvider is iterative
from the root of the stack. * <p>This method was refactored from  {@link org.apache.struts2.components.Text}
to use a * consistent implementation across UIBean components.</p> * @param key    
        the message key in the resource bundle * @param defaultMessage  the message to return
if not found * @param stack           the value stack to use for finding the text * * @return
the message if found, otherwise the defaultMessage */ public static String getText(String
key, String defaultMessage, ValueStack stack) { return getText(key, defaultMessage, Collections.emptyList(),
stack); }
}


Le Dimanche 24 août 2014 11h47, Lukasz Lenart <lukaszlenart@apache.org> a écrit :
 


2014-08-23 18:05 GMT+02:00 Amine BADID <aminebadid@yahoo.fr>:
> Hi All.
> I have a procblem with Struts2 about Internationation exactly.
> Here is the error message :
> - 2014-08-23 17:55:39,643 WARN [org.apache.struts2.util.TextProviderHelper] - <The
default value expression 'Menu.logout' was evaluated and did not match a property.  The literal
value 'Menu.logout' will be used.>
> I can have the english properties but I cannot have any other language properties. It
works only with the english traduction !!!
>
> In the begginning, I had not this problem. I had it only since yesterday !!

Maybe you should first check what have changed from yesterday??????????


> I have tow files :
> global_en.properties and global_fr.properties

First you must have global.properties that matches your default
locale, that's how I18N bundles work in Java.


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message