Skip to content

Commit cac1961

Browse files
committed
Revert "Reverted changes in obsolete hipparchus-migration module."
This reverts commit a68a267.
1 parent a68a267 commit cac1961

File tree

2 files changed

+11
-25
lines changed

2 files changed

+11
-25
lines changed

hipparchus-migration/src/main/java/org/hipparchus/migration/LocalizedMigrationFormats.java

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,8 @@
2222
package org.hipparchus.migration;
2323

2424
import java.util.Locale;
25-
import java.util.MissingResourceException;
26-
import java.util.ResourceBundle;
2725

2826
import org.hipparchus.exception.Localizable;
29-
import org.hipparchus.exception.UTF8Control;
3027

3128
/**
3229
* Enumeration for localized messages formats used in exceptions messages.
@@ -313,28 +310,8 @@ public String getSourceString() {
313310
/** {@inheritDoc} */
314311
@Override
315312
public String getLocalizedString(final Locale locale) {
316-
try {
317-
final String path = LocalizedMigrationFormats.class.getName().replaceAll("\\.", "/");
318-
ResourceBundle bundle =
319-
ResourceBundle.getBundle("assets/" + path, locale, new UTF8Control());
320-
if (bundle.getLocale().getLanguage().equals(locale.getLanguage())) {
321-
final String translated = bundle.getString(name());
322-
if ((translated != null) &&
323-
(translated.length() > 0) &&
324-
(!translated.toLowerCase(locale).contains("missing translation"))) {
325-
// the value of the resource is the translated format
326-
return translated;
327-
}
328-
}
329-
330-
} catch (MissingResourceException mre) { // NOPMD
331-
// do nothing here
332-
}
333-
334-
// either the locale is not supported or the resource is unknown
335-
// don't translate and fall back to using the source format
336-
return sourceFormat;
337-
313+
return getLocalizedString("assets/" + LocalizedMigrationFormats.class.getName().replaceAll("\\.", "/"),
314+
name(), locale);
338315
}
339316

340317
}

hipparchus-migration/src/test/java/org/hipparchus/migration/LocalizedMigrationFormatsTest.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@
2424

2525

2626
import org.hipparchus.exception.LocalizedFormatsAbstractTest;
27+
import org.junit.jupiter.api.Test;
28+
import org.junit.jupiter.api.Assertions;
29+
30+
import java.util.Locale;
2731

2832
@Deprecated
2933
public class LocalizedMigrationFormatsTest extends LocalizedFormatsAbstractTest {
@@ -38,4 +42,9 @@ protected int getExpectedNumber() {
3842
return 82;
3943
}
4044

45+
@Test
46+
public void testUnsupportedLocale() {
47+
Assertions.assertEquals("Cardan angles singularity",
48+
LocalizedMigrationFormats.CARDAN_ANGLES_SINGULARITY.getLocalizedString(Locale.TRADITIONAL_CHINESE));
49+
}
4150
}

0 commit comments

Comments
 (0)