You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by de...@apache.org on 2019/10/29 10:30:21 UTC
[sis] branch geoapi-4.0 updated: If the locale starts with a #
character (e.g. "#fra"), skip the "#" character.
This is an automated email from the ASF dual-hosted git repository.
desruisseaux pushed a commit to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git
The following commit(s) were added to refs/heads/geoapi-4.0 by this push:
new 9c79f39 If the locale starts with a # character (e.g. "#fra"), skip the "#" character.
9c79f39 is described below
commit 9c79f39f2c354987f36616f1f6d95ef5a8286b49
Author: Martin Desruisseaux <ma...@geomatys.com>
AuthorDate: Tue Oct 29 11:29:31 2019 +0100
If the locale starts with a # character (e.g. "#fra"), skip the "#" character.
---
.../apache/sis/internal/jaxb/lan/LocalisedCharacterString.java | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/lan/LocalisedCharacterString.java b/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/lan/LocalisedCharacterString.java
index 476015d..92798af 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/lan/LocalisedCharacterString.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/lan/LocalisedCharacterString.java
@@ -95,10 +95,16 @@ final class LocalisedCharacterString {
* @param localeId the new locale.
* @see <a href="https://issues.apache.org/jira/browse/SIS-137">SIS-137</a>
*/
- public void setLocale(final String localeId) {
+ public void setLocale(String localeId) {
if (localeId != null) {
+ /*
+ * If the URI contains #, skip all characters up to that '#' (otherwise do nothing).
+ * Then if there is a "locale-" string after that point, skip also that "locale-".
+ */
+ final int start = localeId.indexOf('#') + 1; // 0 if # is not found.
+ localeId = localeId.substring(Math.max(localeId.indexOf('-', start) + 1, start));
final Context context = Context.current();
- locale = Context.converter(context).toLocale(context, localeId.substring(localeId.indexOf('-') + 1));
+ locale = Context.converter(context).toLocale(context, localeId);
} else {
locale = null;
}