Fix locale parsing error with en_en, tr_tr, etc
Previously, StringUtils#parseLocaleString would parse locale strings having the same lowercase token for both language and country incorrectly, e.g. 'tr_tr' would parse to 'tr_TR_tr' as opposed to the expected 'tr_TR'. This commit fixes this behavior by using using String#lastIndexOf instead of String#indexOf when determining the location of the country code token. Issue: SPR-9420
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2011 the original author or authors.
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -674,7 +674,7 @@ public abstract class StringUtils {
|
||||
if (parts.length >= 2) {
|
||||
// There is definitely a variant, and it is everything after the country
|
||||
// code sans the separator between the country code and the variant.
|
||||
int endIndexOfCountryCode = localeString.indexOf(country) + country.length();
|
||||
int endIndexOfCountryCode = localeString.lastIndexOf(country) + country.length();
|
||||
// Strip off any leading '_' and whitespace, what's left is the variant.
|
||||
variant = trimLeadingWhitespace(localeString.substring(endIndexOfCountryCode));
|
||||
if (variant.startsWith("_")) {
|
||||
|
||||
Reference in New Issue
Block a user