mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-10 12:09:27 +01:00
add CroatianTransliterator
This commit is contained in:
parent
2a5cd559d5
commit
da001544c5
@ -56,6 +56,7 @@ import nodomain.freeyourgadget.gadgetbridge.util.language.impl.ScandinavianTrans
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.language.impl.TurkishTransliterator;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.language.impl.UkranianTransliterator;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.language.impl.GeorgianTransliterator;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.language.impl.CroatianTransliterator;
|
||||
|
||||
public class LanguageUtils {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(LanguageUtils.class);
|
||||
@ -63,6 +64,7 @@ public class LanguageUtils {
|
||||
private static final Map<String, Transliterator> TRANSLITERATORS_MAP = new HashMap<String, Transliterator>() {{
|
||||
put("arabic", new ArabicTransliterator());
|
||||
put("bengali", new BengaliTransliterator());
|
||||
put("croatian", new CroatianTransliterator());
|
||||
put("czech", new CzechTransliterator());
|
||||
put("estonian", new EstonianTransliterator());
|
||||
put("extended_ascii", new ExtendedAsciiTransliterator());
|
||||
|
@ -0,0 +1,36 @@
|
||||
/* Copyright (C) 2017-2022 Andreas Shimokawa, Aniruddha Adhikary, Daniele
|
||||
Gobbetti, ivanovlev, kalaee, lazarosfs, McSym28, M. Hadi, Roi Greenberg,
|
||||
Taavi Eomäe, Ted Stein, Thomas, Yaron Shahrabani, José Rebelo
|
||||
|
||||
This file is part of Gadgetbridge.
|
||||
|
||||
Gadgetbridge is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published
|
||||
by the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Gadgetbridge is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
package nodomain.freeyourgadget.gadgetbridge.util.language.impl;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.language.SimpleTransliterator;
|
||||
|
||||
public class CroatianTransliterator extends SimpleTransliterator {
|
||||
public CroatianTransliterator() {
|
||||
super(new HashMap<Character, String>() {{
|
||||
put('Č', "C"); put('č', "c");
|
||||
put('Ć', "C"); put('ć', "c");
|
||||
put('Đ', "D"); put('đ', "d");
|
||||
put('Š', "S"); put('š', "s");
|
||||
put('Ž', "z"); put('ž', "z");
|
||||
}});
|
||||
}
|
||||
}
|
||||
|
@ -2781,6 +2781,7 @@
|
||||
<string-array name="pref_transliteration_languages">
|
||||
<item>@string/arabic</item>
|
||||
<item>@string/bengali</item>
|
||||
<item>@string/croatian</item>
|
||||
<item>@string/czech</item>
|
||||
<item>@string/estonian</item>
|
||||
<item>@string/extended_ascii</item>
|
||||
@ -2803,6 +2804,7 @@
|
||||
<string-array name="pref_transliteration_languages_values">
|
||||
<item>arabic</item>
|
||||
<item>bengali</item>
|
||||
<item>croatian</item>
|
||||
<item>czech</item>
|
||||
<item>estonian</item>
|
||||
<item>extended_ascii</item>
|
||||
|
@ -918,6 +918,7 @@
|
||||
<string name="georgian">Georgian</string>
|
||||
<string name="german">German</string>
|
||||
<string name="bengali">Bengali</string>
|
||||
<string name="croatian">Croatian</string>
|
||||
<string name="czech">Czech</string>
|
||||
<string name="estonian">Estonian</string>
|
||||
<string name="extended_ascii">Extended ASCII</string>
|
||||
|
@ -173,6 +173,16 @@ public class LanguageUtilsTest extends TestBase {
|
||||
assertEquals("georgian transliteration failed", expected, output);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStringTransliterateCroatian() {
|
||||
final Transliterator transliterator = LanguageUtils.getTransliterator("croatian");
|
||||
|
||||
String input = "č ć đ š ž";
|
||||
String output = transliterator.transliterate(input);
|
||||
String expected = "c c d s z";
|
||||
assertEquals("croatian transliteration failed", expected, output);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTransliterateOption() throws Exception {
|
||||
enableTransliteration(false);
|
||||
@ -187,7 +197,7 @@ public class LanguageUtilsTest extends TestBase {
|
||||
SharedPreferences devicePrefs = GBApplication.getDeviceSpecificSharedPrefs(dummyGBDevice.getAddress());
|
||||
SharedPreferences.Editor editor = devicePrefs.edit();
|
||||
if (enable) {
|
||||
editor.putString(PREF_TRANSLITERATION_LANGUAGES, "extended_ascii,scandinavian,german,russian,hebrew,greek,ukranian,arabic,persian,lithuanian,polish,estonian,icelandic,czech,turkish,bengali,korean,georgian");
|
||||
editor.putString(PREF_TRANSLITERATION_LANGUAGES, "extended_ascii,scandinavian,german,russian,hebrew,greek,ukranian,arabic,persian,lithuanian,polish,estonian,icelandic,czech,turkish,bengali,korean,georgian,croatian");
|
||||
} else {
|
||||
editor.remove(PREF_TRANSLITERATION_LANGUAGES);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user