|
List Info
Thread: Created: (STR-2923) PropertyMessageResources.getMessage uses loadLocale in wrong order
|
|
| Created: (STR-2923)
PropertyMessageResources.getMessage uses
loadLocale in wrong order |

|
2006-08-09 10:47:21 |
PropertyMessageResources.getMessage uses loadLocale in wrong
order
------------------------------------------------------------
------
Key: STR-2923
URL: http:
//issues.apache.org/struts/browse/STR-2923
Project: Struts 1
Issue Type: Bug
Affects Versions: 1.2 Family
Environment: default locale on windows platform is
fi_FI
Reporter: Antti Tirkkonen
Priority: Minor
if you have following messagebundles:
bundle_fi.properties
bundle.properties
And want to any other locale except fi to use
bundle.properties. It is not possible without setting JVM
default locale something else than fi locale. Problem with
this approach is that you possible end up effecting
behaviour of other software running on the same JVM.
To solve this problem PropertyMessageResources.getMessage
implementation
could be changed to do locale loading in different order.
current order is: asked locale, asked locale minus
underscore, JVM default locale, no locale
proposed order: asked locale, asked locale minus underscore,
no locale, JVM default locale
Current code:
public String getMessage(Locale locale, String key) {
if (log.isDebugEnabled()) {
log.debug("getMessage(" + locale +
"," + key + ")");
}
String localeKey = localeKey(locale);
String originalKey = messageKey(localeKey, key);
String messageKey = null;
String message = null;
int underscore = 0;
boolean addIt = false;
while (true) {
loadLocale(localeKey);
messageKey = messageKey(localeKey, key);
synchronized (messages) {
message =
(String)messages.get(messageKey);
if (message != null) {
if (addIt) {
messages.put(originalKey,
message);
}
return (message);
}
}
addIt = true;
underscore =
localeKey.lastIndexOf("_");
if (underscore < 0) {
break;
}
localeKey = localeKey.substring(0,
underscore);
}
if (!defaultLocale.equals(locale)) {
localeKey = localeKey(defaultLocale);
messageKey = messageKey(localeKey, key);
loadLocale(localeKey);
synchronized (messages) {
message =
(String)messages.get(messageKey);
if (message != null) {
messages.put(originalKey, message);
return (message);
}
}
}
localeKey = "";
messageKey = messageKey(localeKey, key);
loadLocale(localeKey);
synchronized (messages) {
message = (String)messages.get(messageKey);
if (message != null) {
messages.put(originalKey, message);
return (message);
}
}
if (returnNull) {
return (null);
} else {
return ("???" + messageKey(locale,
key) + "???");
}
}
proposed code:
public String getMessage(Locale locale, String key) {
if (log.isDebugEnabled()) {
log.debug("getMessage(" + locale +
"," + key + ")");
}
String localeKey = localeKey(locale);
String originalKey = messageKey(localeKey, key);
String messageKey = null;
String message = null;
int underscore = 0;
boolean addIt = false;
while (true) {
loadLocale(localeKey);
messageKey = messageKey(localeKey, key);
synchronized (messages) {
message =
(String)messages.get(messageKey);
if (message != null) {
if (addIt) {
messages.put(originalKey,
message);
}
return (message);
}
}
addIt = true;
underscore =
localeKey.lastIndexOf("_");
if (underscore < 0) {
break;
}
localeKey = localeKey.substring(0,
underscore);
}
localeKey = "";
messageKey = messageKey(localeKey, key);
loadLocale(localeKey);
synchronized (messages) {
message = (String)messages.get(messageKey);
if (message != null) {
messages.put(originalKey, message);
return (message);
}
}
if (!defaultLocale.equals(locale)) {
localeKey = localeKey(defaultLocale);
messageKey = messageKey(localeKey, key);
loadLocale(localeKey);
synchronized (messages) {
message =
(String)messages.get(messageKey);
if (message != null) {
messages.put(originalKey, message);
return (message);
}
}
}
if (returnNull) {
return (null);
} else {
return ("???" + messageKey(locale,
key) + "???");
}
}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the
administrators: http://issues.apache.org/struts/secure/Administrators.
jspa
-
For more information on JIRA, see: http://www.atl
assian.com/software/jira
|
|
| Updated: (STR-2923)
PropertyMessageResources.getMessage uses
loadLocale in wrong order |

|
2006-11-26 05:59:57 |
[ http://issues.apache.org/struts/browse/STR-2923?page=all
]
Paul Benedict updated STR-2923:
-------------------------------
Component/s: Core
Fix Version/s: 1.3.6
Affects Version/s: 1.3.5
1.2.9
> PropertyMessageResources.getMessage uses loadLocale in
wrong order
>
------------------------------------------------------------
------
>
> Key: STR-2923
> URL: http:
//issues.apache.org/struts/browse/STR-2923
> Project: Struts 1
> Issue Type: Bug
> Components: Core
> Affects Versions: 1.2.9, 1.2 Family, 1.3.5
> Environment: default locale on windows platform
is fi_FI
> Reporter: Antti Tirkkonen
> Priority: Minor
> Fix For: 1.3.6
>
>
> if you have following messagebundles:
> bundle_fi.properties
> bundle.properties
> And want to any other locale except fi to use
bundle.properties. It is not possible without setting JVM
default locale something else than fi locale. Problem with
this approach is that you possible end up effecting
behaviour of other software running on the same JVM.
> To solve this problem
PropertyMessageResources.getMessage implementation
> could be changed to do locale loading in different
order.
> current order is: asked locale, asked locale minus
underscore, JVM default locale, no locale
> proposed order: asked locale, asked locale minus
underscore, no locale, JVM default locale
> Current code:
> public String getMessage(Locale locale, String key)
{
> if (log.isDebugEnabled()) {
> log.debug("getMessage(" +
locale + "," + key + ")");
> }
> String localeKey = localeKey(locale);
> String originalKey = messageKey(localeKey,
key);
> String messageKey = null;
> String message = null;
> int underscore = 0;
> boolean addIt = false;
> while (true) {
> loadLocale(localeKey);
> messageKey = messageKey(localeKey, key);
> synchronized (messages) {
> message =
(String)messages.get(messageKey);
> if (message != null) {
> if (addIt) {
> messages.put(originalKey,
message);
> }
> return (message);
> }
> }
> addIt = true;
> underscore =
localeKey.lastIndexOf("_");
> if (underscore < 0) {
> break;
> }
> localeKey = localeKey.substring(0,
underscore);
> }
> if (!defaultLocale.equals(locale)) {
> localeKey = localeKey(defaultLocale);
> messageKey = messageKey(localeKey, key);
> loadLocale(localeKey);
> synchronized (messages) {
> message =
(String)messages.get(messageKey);
> if (message != null) {
> messages.put(originalKey,
message);
> return (message);
> }
> }
> }
> localeKey = "";
> messageKey = messageKey(localeKey, key);
> loadLocale(localeKey);
> synchronized (messages) {
> message =
(String)messages.get(messageKey);
> if (message != null) {
> messages.put(originalKey, message);
> return (message);
> }
> }
> if (returnNull) {
> return (null);
> } else {
> return ("???" +
messageKey(locale, key) + "???");
> }
> }
> proposed code:
> public String getMessage(Locale locale, String key)
{
> if (log.isDebugEnabled()) {
> log.debug("getMessage(" +
locale + "," + key + ")");
> }
> String localeKey = localeKey(locale);
> String originalKey = messageKey(localeKey,
key);
> String messageKey = null;
> String message = null;
> int underscore = 0;
> boolean addIt = false;
> while (true) {
> loadLocale(localeKey);
> messageKey = messageKey(localeKey, key);
> synchronized (messages) {
> message =
(String)messages.get(messageKey);
> if (message != null) {
> if (addIt) {
> messages.put(originalKey,
message);
> }
> return (message);
> }
> }
> addIt = true;
> underscore =
localeKey.lastIndexOf("_");
> if (underscore < 0) {
> break;
> }
> localeKey = localeKey.substring(0,
underscore);
> }
> localeKey = "";
> messageKey = messageKey(localeKey, key);
> loadLocale(localeKey);
> synchronized (messages) {
> message =
(String)messages.get(messageKey);
> if (message != null) {
> messages.put(originalKey, message);
> return (message);
> }
> }
> if (!defaultLocale.equals(locale)) {
> localeKey = localeKey(defaultLocale);
> messageKey = messageKey(localeKey, key);
> loadLocale(localeKey);
> synchronized (messages) {
> message =
(String)messages.get(messageKey);
> if (message != null) {
> messages.put(originalKey,
message);
> return (message);
> }
> }
> }
> if (returnNull) {
> return (null);
> } else {
> return ("???" +
messageKey(locale, key) + "???");
> }
> }
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the
administrators: http://issues.apache.org/struts/secure/Administrators.
jspa
-
For more information on JIRA, see: http://www.atl
assian.com/software/jira
|
|
| Updated: (STR-2923)
PropertyMessageResources.getMessage uses
loadLocale in wrong order |

|
2006-11-27 19:49:57 |
[ http://issues.apache.org/struts/browse/STR-2923?page=all
]
Paul Benedict updated STR-2923:
-------------------------------
Fix Version/s: 1.3.7
(was: 1.3.6)
> PropertyMessageResources.getMessage uses loadLocale in
wrong order
>
------------------------------------------------------------
------
>
> Key: STR-2923
> URL: http:
//issues.apache.org/struts/browse/STR-2923
> Project: Struts 1
> Issue Type: Bug
> Components: Core
> Affects Versions: 1.2 Family, 1.3.5, 1.2.9
> Environment: default locale on windows platform
is fi_FI
> Reporter: Antti Tirkkonen
> Priority: Minor
> Fix For: 1.3.7
>
>
> if you have following messagebundles:
> bundle_fi.properties
> bundle.properties
> And want to any other locale except fi to use
bundle.properties. It is not possible without setting JVM
default locale something else than fi locale. Problem with
this approach is that you possible end up effecting
behaviour of other software running on the same JVM.
> To solve this problem
PropertyMessageResources.getMessage implementation
> could be changed to do locale loading in different
order.
> current order is: asked locale, asked locale minus
underscore, JVM default locale, no locale
> proposed order: asked locale, asked locale minus
underscore, no locale, JVM default locale
> Current code:
> public String getMessage(Locale locale, String key)
{
> if (log.isDebugEnabled()) {
> log.debug("getMessage(" +
locale + "," + key + ")");
> }
> String localeKey = localeKey(locale);
> String originalKey = messageKey(localeKey,
key);
> String messageKey = null;
> String message = null;
> int underscore = 0;
> boolean addIt = false;
> while (true) {
> loadLocale(localeKey);
> messageKey = messageKey(localeKey, key);
> synchronized (messages) {
> message =
(String)messages.get(messageKey);
> if (message != null) {
> if (addIt) {
> messages.put(originalKey,
message);
> }
> return (message);
> }
> }
> addIt = true;
> underscore =
localeKey.lastIndexOf("_");
> if (underscore < 0) {
> break;
> }
> localeKey = localeKey.substring(0,
underscore);
> }
> if (!defaultLocale.equals(locale)) {
> localeKey = localeKey(defaultLocale);
> messageKey = messageKey(localeKey, key);
> loadLocale(localeKey);
> synchronized (messages) {
> message =
(String)messages.get(messageKey);
> if (message != null) {
> messages.put(originalKey,
message);
> return (message);
> }
> }
> }
> localeKey = "";
> messageKey = messageKey(localeKey, key);
> loadLocale(localeKey);
> synchronized (messages) {
> message =
(String)messages.get(messageKey);
> if (message != null) {
> messages.put(originalKey, message);
> return (message);
> }
> }
> if (returnNull) {
> return (null);
> } else {
> return ("???" +
messageKey(locale, key) + "???");
> }
> }
> proposed code:
> public String getMessage(Locale locale, String key)
{
> if (log.isDebugEnabled()) {
> log.debug("getMessage(" +
locale + "," + key + ")");
> }
> String localeKey = localeKey(locale);
> String originalKey = messageKey(localeKey,
key);
> String messageKey = null;
> String message = null;
> int underscore = 0;
> boolean addIt = false;
> while (true) {
> loadLocale(localeKey);
> messageKey = messageKey(localeKey, key);
> synchronized (messages) {
> message =
(String)messages.get(messageKey);
> if (message != null) {
> if (addIt) {
> messages.put(originalKey,
message);
> }
> return (message);
> }
> }
> addIt = true;
> underscore =
localeKey.lastIndexOf("_");
> if (underscore < 0) {
> break;
> }
> localeKey = localeKey.substring(0,
underscore);
> }
> localeKey = "";
> messageKey = messageKey(localeKey, key);
> loadLocale(localeKey);
> synchronized (messages) {
> message =
(String)messages.get(messageKey);
> if (message != null) {
> messages.put(originalKey, message);
> return (message);
> }
> }
> if (!defaultLocale.equals(locale)) {
> localeKey = localeKey(defaultLocale);
> messageKey = messageKey(localeKey, key);
> loadLocale(localeKey);
> synchronized (messages) {
> message =
(String)messages.get(messageKey);
> if (message != null) {
> messages.put(originalKey,
message);
> return (message);
> }
> }
> }
> if (returnNull) {
> return (null);
> } else {
> return ("???" +
messageKey(locale, key) + "???");
> }
> }
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the
administrators: http://issues.apache.org/struts/secure/Administrators.
jspa
-
For more information on JIRA, see: http://www.atl
assian.com/software/jira
|
|
| Resolved: (STR-2923)
PropertyMessageResources.getMessage uses
loadLocale in wrong order |

|
2006-11-29 12:33:58 |
[ http://issues.apache.org/struts/browse/STR-2923?page=all
]
Niall Pemberton resolved STR-2923.
----------------------------------
Fix Version/s: (was: 1.3.7)
Resolution: Duplicate
This issue has been resolved by STR-2925 -
PropertyMessageResources can now be configured to operate in
one of three modes. See STR-2925 for details.
> PropertyMessageResources.getMessage uses loadLocale in
wrong order
>
------------------------------------------------------------
------
>
> Key: STR-2923
> URL: http:
//issues.apache.org/struts/browse/STR-2923
> Project: Struts 1
> Issue Type: Bug
> Components: Core
> Affects Versions: 1.2.9, 1.2 Family, 1.3.5
> Environment: default locale on windows platform
is fi_FI
> Reporter: Antti Tirkkonen
> Priority: Minor
>
> if you have following messagebundles:
> bundle_fi.properties
> bundle.properties
> And want to any other locale except fi to use
bundle.properties. It is not possible without setting JVM
default locale something else than fi locale. Problem with
this approach is that you possible end up effecting
behaviour of other software running on the same JVM.
> To solve this problem
PropertyMessageResources.getMessage implementation
> could be changed to do locale loading in different
order.
> current order is: asked locale, asked locale minus
underscore, JVM default locale, no locale
> proposed order: asked locale, asked locale minus
underscore, no locale, JVM default locale
> Current code:
> public String getMessage(Locale locale, String key)
{
> if (log.isDebugEnabled()) {
> log.debug("getMessage(" +
locale + "," + key + ")");
> }
> String localeKey = localeKey(locale);
> String originalKey = messageKey(localeKey,
key);
> String messageKey = null;
> String message = null;
> int underscore = 0;
> boolean addIt = false;
> while (true) {
> loadLocale(localeKey);
> messageKey = messageKey(localeKey, key);
> synchronized (messages) {
> message =
(String)messages.get(messageKey);
> if (message != null) {
> if (addIt) {
> messages.put(originalKey,
message);
> }
> return (message);
> }
> }
> addIt = true;
> underscore =
localeKey.lastIndexOf("_");
> if (underscore < 0) {
> break;
> }
> localeKey = localeKey.substring(0,
underscore);
> }
> if (!defaultLocale.equals(locale)) {
> localeKey = localeKey(defaultLocale);
> messageKey = messageKey(localeKey, key);
> loadLocale(localeKey);
> synchronized (messages) {
> message =
(String)messages.get(messageKey);
> if (message != null) {
> messages.put(originalKey,
message);
> return (message);
> }
> }
> }
> localeKey = "";
> messageKey = messageKey(localeKey, key);
> loadLocale(localeKey);
> synchronized (messages) {
> message =
(String)messages.get(messageKey);
> if (message != null) {
> messages.put(originalKey, message);
> return (message);
> }
> }
> if (returnNull) {
> return (null);
> } else {
> return ("???" +
messageKey(locale, key) + "???");
> }
> }
> proposed code:
> public String getMessage(Locale locale, String key)
{
> if (log.isDebugEnabled()) {
> log.debug("getMessage(" +
locale + "," + key + ")");
> }
> String localeKey = localeKey(locale);
> String originalKey = messageKey(localeKey,
key);
> String messageKey = null;
> String message = null;
> int underscore = 0;
> boolean addIt = false;
> while (true) {
> loadLocale(localeKey);
> messageKey = messageKey(localeKey, key);
> synchronized (messages) {
> message =
(String)messages.get(messageKey);
> if (message != null) {
> if (addIt) {
> messages.put(originalKey,
message);
> }
> return (message);
> }
> }
> addIt = true;
> underscore =
localeKey.lastIndexOf("_");
> if (underscore < 0) {
> break;
> }
> localeKey = localeKey.substring(0,
underscore);
> }
> localeKey = "";
> messageKey = messageKey(localeKey, key);
> loadLocale(localeKey);
> synchronized (messages) {
> message =
(String)messages.get(messageKey);
> if (message != null) {
> messages.put(originalKey, message);
> return (message);
> }
> }
> if (!defaultLocale.equals(locale)) {
> localeKey = localeKey(defaultLocale);
> messageKey = messageKey(localeKey, key);
> loadLocale(localeKey);
> synchronized (messages) {
> message =
(String)messages.get(messageKey);
> if (message != null) {
> messages.put(originalKey,
message);
> return (message);
> }
> }
> }
> if (returnNull) {
> return (null);
> } else {
> return ("???" +
messageKey(locale, key) + "???");
> }
> }
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the
administrators: http://issues.apache.org/struts/secure/Administrators.
jspa
-
For more information on JIRA, see: http://www.atl
assian.com/software/jira
|
|
[1-4]
|
|