PseudoLocalization { public String convertStringToPseudoLoc(String string, Set<TextUnitIntegrityChecker> checkers) { TextUnitIntegrityChecker checker = getIntegrityCheckerForPlaceholderProcessing(checkers); if (checker == null) { logger.debug("There is no checker for pseudolocalization placeholder processing."); return convertStringToPseudoLoc(string); } else { logger.debug("Found checker for pseudolocalization placeholder processing."); LocalizableString localizableString = checker.extractNonLocalizableParts(string); String pseudolocalized = convertStringToPseudoLoc(localizableString.getLocalizableString()); localizableString.setLocalizableString(pseudolocalized); return checker.restoreNonLocalizableParts(localizableString); } }  String convertStringToPseudoLoc(String string, Set<TextUnitIntegrityChecker> checkers); String convertStringToPseudoLoc(String string); String expand(String string); String convertAsciiToDiacritics(String string);  }
@Test public void testconvertStringToPseudoLoc() { PseudoLocalization ps = new PseudoLocalization(); String pseudoLocalized = ps.convertStringToPseudoLoc("English Sentence"); assertNotEquals("The string should be pseudolocalized", "English Sentence", pseudoLocalized); }
@Test public void testconvertStringToPseudoLocDoesNot() { PseudoLocalization ps = new PseudoLocalization(); String pseudoLocalized = ps.convertStringToPseudoLoc(""); assertEquals("The strings should be equal", "", pseudoLocalized); }
@Test public void testConvertStringToPseudoLocWithNoIntegrityChecker() { PseudoLocalization ps = new PseudoLocalization(); Set<TextUnitIntegrityChecker> checkers = new HashSet<>(); String pseudoLocalized = ps.convertStringToPseudoLoc("vf", checkers); assertEquals("The strings should be equal", "⟦ νƒ ⟧", pseudoLocalized); }
@Test public void testConvertStringToPseudoLocWithMultipleIntegrityCheckers() { PseudoLocalization ps = new PseudoLocalization(); Set<TextUnitIntegrityChecker> checkers = new HashSet<>(); checkers.add(new WhitespaceIntegrityChecker()); checkers.add(new MessageFormatIntegrityChecker()); String pseudoLocalized = ps.convertStringToPseudoLoc("vf", checkers); assertEquals("The strings should be equal", "⟦ νƒ ⟧", pseudoLocalized); }
@Test public void testConvertMessageFormatStringToPseudoLoc() { PseudoLocalization ps = new PseudoLocalization(); Set<TextUnitIntegrityChecker> checkers = new HashSet<>(); checkers.add(new MessageFormatIntegrityChecker()); String pseudoLocalized = ps.convertStringToPseudoLoc("English Sentence with {placeholder1} and {placeholder2} which should not be pseudolocalized", checkers); assertTrue("The placeholder should not be pseudolocalized", pseudoLocalized.contains("{placeholder1}")); assertTrue("The placeholder should not be pseudolocalized", pseudoLocalized.contains("{placeholder2}")); }
@Test public void testConvertPluralMessageFormatStringToPseudoLoc1() { PseudoLocalization ps = new PseudoLocalization(); Set<TextUnitIntegrityChecker> checkers = new HashSet<>(); checkers.add(new MessageFormatIntegrityChecker()); String pseudoLocalized = ps.convertStringToPseudoLoc("Test {count, plural, one {# v} other {# vf}} with Plurals", checkers); assertTrue("The plural syntax should not be pseudolocalized", pseudoLocalized.contains("count, plural, one")); assertTrue("The plural syntax should not be pseudolocalized", pseudoLocalized.contains("other")); assertTrue("The plural text variation should be pseudolocalized", pseudoLocalized.contains("{# ν}")); assertTrue("The plural text variation should be pseudolocalized", pseudoLocalized.contains("{# νƒ}")); }
@Test public void testConvertPluralMessageFormatStringToPseudoLoc2() { PseudoLocalization ps = new PseudoLocalization(); Set<TextUnitIntegrityChecker> checkers = new HashSet<>(); checkers.add(new MessageFormatIntegrityChecker()); String pseudoLocalized = ps.convertStringToPseudoLoc("Viewed by {numUsers, plural, one {1 v} other {{numUsers} vf}} and others", checkers); assertFalse("The string should be pseudolocalized", pseudoLocalized.contains("Viewed by")); assertTrue("The plural syntax should not be pseudolocalized", pseudoLocalized.contains("numUsers, plural, one")); assertTrue("The plural syntax should not be pseudolocalized", pseudoLocalized.contains("other")); assertTrue("The plural text variation should be pseudolocalized", pseudoLocalized.contains("{1 ν}")); assertTrue("The plural text variation should be pseudolocalized while the placeholder should not", pseudoLocalized.contains("{{numUsers} νƒ}")); }
@Test public void testConvertPluralMessageFormatStringToPseudoLoc3() { PseudoLocalization ps = new PseudoLocalization(); Set<TextUnitIntegrityChecker> checkers = new HashSet<>(); checkers.add(new MessageFormatIntegrityChecker()); String pseudoLocalized = ps.convertStringToPseudoLoc("{count, plural, one {# Comment or Task} other {# Comments or Tasks}}", checkers); assertTrue("The plural syntax should not be pseudolocalized", pseudoLocalized.contains("count, plural, one")); assertTrue("The plural syntax should not be pseudolocalized", pseudoLocalized.contains("other")); assertFalse("The plural text variation should be pseudolocalized", pseudoLocalized.contains("{# Comment or Task}")); assertFalse("The plural text variation should be pseudolocalized while the placeholder should not", pseudoLocalized.contains("{# Comments or Tasks}")); }