1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-12-25 18:15:49 +01:00

Added Hebrew transliteration and tests (#571)

This commit is contained in:
Yaron Shahrabani 2017-03-04 23:08:24 +02:00 committed by Andreas Shimokawa
parent 58e2538c4e
commit 858eaa6690
3 changed files with 32 additions and 3 deletions

View File

@ -21,6 +21,11 @@ public class LanguageUtils {
put('ч', "ch");put('ш', "sh");put('щ', "shh");put('ъ', "\"");put('ы', "y"); put('ь', "'"); put('э', "eh"); put('ю', "ju");
put('я', "ja");
//hebrew chars
put('א', "a"); put('ב', "b"); put('ג', "g"); put('ד', "d"); put('ה', "h"); put('ו', "u"); put('ז', "z"); put('ח', "kh");
put('ט', "t"); put('י', "y"); put('כ', "c"); put('ל', "l"); put('מ', "m"); put('נ', "n"); put('ס', "s"); put('ע', "'");
put('פ', "p"); put('צ', "ts"); put('ק', "k"); put('ר', "r"); put('ש', "sh"); put('ת', "th"); put('ף', "f"); put('ץ', "ts");
put('ך', "ch");put('ם', "m");put('ן', "n");
//continue for other languages...
}
};

View File

@ -102,7 +102,7 @@ public class DeviceCommunicationServiceTestCase extends TestBase {
}
@Test
public void testTransliterationSupport() {
public void testTransliterationSupportCyrillic() {
SharedPreferences settings = GBApplication.getPrefs().getPreferences();
SharedPreferences.Editor editor = settings.edit();
editor.putBoolean("transliteration", true);
@ -114,4 +114,18 @@ public class DeviceCommunicationServiceTestCase extends TestBase {
assertTrue("Transliteration support fail!", result.equals("Prosto tekct"));
}
@Test
public void testTransliterationSupportHebrew() {
SharedPreferences settings = GBApplication.getPrefs().getPreferences();
SharedPreferences.Editor editor = settings.edit();
editor.putBoolean("transliteration", true);
editor.commit();
Intent intent = mDeviceService.createIntent().putExtra(EXTRA_NOTIFICATION_BODY, "בדיקה עברית");
mDeviceService.invokeService(intent);
String result = intent.getStringExtra(EXTRA_NOTIFICATION_BODY);
assertTrue("Transliteration support fail!", result.equals("bdykh 'vrith"));
}
}

View File

@ -15,7 +15,7 @@ import static org.junit.Assert.assertTrue;
*/
public class LanguageUtilsTest extends TestBase {
@Test
public void testStringTransliterate() throws Exception {
public void testStringTransliterateCyrillic() throws Exception {
//input with cyrillic and diacritic letters
String input = "Прõсто текčт";
String output = LanguageUtils.transliterate(input);
@ -24,6 +24,16 @@ public class LanguageUtilsTest extends TestBase {
assertTrue(String.format("Transliteration fail! Expected '%s', but found '%s'}", result, output), output.equals(result));
}
@Test
public void testStringTransliterateCyrillic() throws Exception {
//input with cyrillic and diacritic letters
String input = "בדיקה עברית";
String output = LanguageUtils.transliterate(input);
String result = "bdykh 'brith";
assertTrue(String.format("Transliteration fail! Expected '%s', but found '%s'}", result, output), output.equals(result));
}
@Test
public void testTransliterateOption() throws Exception {
assertFalse("Transliteration option fail! Expected 'Off' by default, but result is 'On'", LanguageUtils.transliterate());