diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/GBApplication.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/GBApplication.java index 375611bab..b0bbb8d8f 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/GBApplication.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/GBApplication.java @@ -1135,7 +1135,7 @@ public class GBApplication extends Application { if (oldVersion < 16) { // If transliteration was enabled for a device, migrate it to the per-language setting - final String defaultLanguagesIfEnabled = "extended_ascii,scandinavian,german,russian,hebrew,greek,ukranian,arabic,persian,lithuanian,polish,estonian,icelandic,czech,turkish,bengali,korean"; + final String defaultLanguagesIfEnabled = "extended_ascii,scandinavian,german,russian,hebrew,greek,ukranian,arabic,persian,latvian,lithuanian,polish,estonian,icelandic,czech,turkish,bengali,korean"; try (DBHandler db = acquireDB()) { final DaoSession daoSession = db.getDaoSession(); final List activeDevices = DBHelper.getActiveDevices(daoSession); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/language/LanguageUtils.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/language/LanguageUtils.java index e8740a853..de436a65d 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/language/LanguageUtils.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/language/LanguageUtils.java @@ -48,6 +48,7 @@ import nodomain.freeyourgadget.gadgetbridge.util.language.impl.GreekTransliterat import nodomain.freeyourgadget.gadgetbridge.util.language.impl.HebrewTransliterator; import nodomain.freeyourgadget.gadgetbridge.util.language.impl.IcelandicTransliterator; import nodomain.freeyourgadget.gadgetbridge.util.language.impl.KoreanTransliterator; +import nodomain.freeyourgadget.gadgetbridge.util.language.impl.LatvianTransliterator; import nodomain.freeyourgadget.gadgetbridge.util.language.impl.LithuanianTransliterator; import nodomain.freeyourgadget.gadgetbridge.util.language.impl.PersianTransliterator; import nodomain.freeyourgadget.gadgetbridge.util.language.impl.PolishTransliterator; @@ -73,6 +74,7 @@ public class LanguageUtils { put("hebrew", new HebrewTransliterator()); put("icelandic", new IcelandicTransliterator()); put("korean", new KoreanTransliterator()); + put("latvian", new LatvianTransliterator()); put("lithuanian", new LithuanianTransliterator()); put("persian", new PersianTransliterator()); put("polish", new PolishTransliterator()); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/language/impl/LatvianTransliterator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/language/impl/LatvianTransliterator.java new file mode 100644 index 000000000..5e14df681 --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/language/impl/LatvianTransliterator.java @@ -0,0 +1,33 @@ +/* Copyright (C) 2017-2023 Andreas Shimokawa, Aniruddha Adhikary, Daniele + Gobbetti, ivanovlev, kalaee, lazarosfs, McSym28, M. Hadi, Roi Greenberg, + Taavi Eomäe, Ted Stein, Thomas, Yaron Shahrabani, José Rebelo, Davis + Mosenkovs + + 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 . */ +package nodomain.freeyourgadget.gadgetbridge.util.language.impl; + +import java.util.HashMap; + +import nodomain.freeyourgadget.gadgetbridge.util.language.SimpleTransliterator; + +public class LatvianTransliterator extends SimpleTransliterator { + public LatvianTransliterator() { + super(new HashMap() {{ + put('ā', "a"); put('č', "c"); put('ē', "e"); put('ģ', "g"); put('ī', "i"); put('ķ', "k"); put('ļ', "l"); put('ņ', "n"); put('š', "s"); put('ū', "u"); put('ž', "z"); + put('Ā', "A"); put('Č', "C"); put('Ē', "E"); put('Ģ', "G"); put('Ī', "I"); put('Ķ', "K"); put('Ļ', "L"); put('Ņ', "N"); put('Š', "S"); put('Ū', "U"); put('Ž', "Z"); + }}); + } +} diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index e345a3f9e..4cd907230 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -3081,6 +3081,7 @@ @string/hebrew @string/icelandic @string/korean + @string/latvian @string/lithuanian @string/persian @string/polish @@ -3104,6 +3105,7 @@ hebrew icelandic korean + latvian lithuanian persian polish diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 49c5aa3a7..13c609834 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -996,6 +996,7 @@ Estonian Extended ASCII Icelandic + Latvian Lithuanian Persian Scandinavian diff --git a/app/src/test/java/nodomain/freeyourgadget/gadgetbridge/util/language/LanguageUtilsTest.java b/app/src/test/java/nodomain/freeyourgadget/gadgetbridge/util/language/LanguageUtilsTest.java index 68e0e89cf..1daf6a2ce 100644 --- a/app/src/test/java/nodomain/freeyourgadget/gadgetbridge/util/language/LanguageUtilsTest.java +++ b/app/src/test/java/nodomain/freeyourgadget/gadgetbridge/util/language/LanguageUtilsTest.java @@ -149,6 +149,21 @@ public class LanguageUtilsTest extends TestBase { assertEquals("Korean transliteration modified a non-Hangul composite", germanExpected, germanActual); } + @Test + public void testStringTransliterateLatvian() { + final Transliterator transliterator = LanguageUtils.getTransliterator("latvian"); + + String input = "ā č ē ģ ī ķ ļ ņ š ū ž Ā Č Ē Ģ Ī Ķ Ļ Ņ Š Ū Ž"; + String output = transliterator.transliterate(input); + String expected = "a c e g i k l n s u z A C E G I K L N S U Z"; + assertEquals("latvian translation failed", expected, output); + + input = "aāa cčc eēe gģg iīi kķk lļl nņn sšs uūu zžz AĀA CČC EĒE GĢG IĪI KĶK LĻL NŅN SŠS UŪU ZŽZ"; + output = transliterator.transliterate(input); + expected = "aaa ccc eee ggg iii kkk lll nnn sss uuu zzz AAA CCC EEE GGG III KKK LLL NNN SSS UUU ZZZ"; + assertEquals("latvian translation failed", expected, output); + } + @Test public void testStringTransliterateLithuanian() { final Transliterator transliterator = LanguageUtils.getTransliterator("lithuanian");