@Test public void testNormalFormat() { System.setProperty("mct.pseudotranslation", "normal"); ResourceBundle origBundle = ResourceBundle.getBundle("properties.PseudoBundle"); ResourceBundle testBundle = BundleFactory.getBundle("properties.PseudoBundle"); String alphabet = origBundle.getString("alphabet"); String special = origBundle.getString("special"); String noTranslation = origBundle.getString("no_normal_translation"); String messageFormat = origBundle.getString("message_format"); String translated = testBundle.getString("message_format"); assertTrue(PseudoBundle.isEnabled(), "Pseudotranslation enabled"); assertEquals(messageFormat.length()+2, translated.length()); boolean inFormat = false; for (int i=0; i<messageFormat.length(); ++i) { char c = messageFormat.charAt(i); if (c == '{') { inFormat = true; } if (!inFormat && noTranslation.indexOf(c) >= 0) { assertEquals(c, translated.charAt(i+1)); } else if (!inFormat && (alphabet.indexOf(c)>=0 || special.indexOf(c)>=0)) { assertTrue(c != translated.charAt(i+1), "Normal translation changes character " + c); } else { assertEquals(c, translated.charAt(i+1)); } if (c == '}') { inFormat = false; } } }
public static boolean isEnabled() { return (getMode() != BundleMode.NO_TRANSLATION); }
PseudoBundle extends ResourceBundle { public static boolean isEnabled() { return (getMode() != BundleMode.NO_TRANSLATION); } }
PseudoBundle extends ResourceBundle { public static boolean isEnabled() { return (getMode() != BundleMode.NO_TRANSLATION); } PseudoBundle(ResourceBundle baseBundle); }
PseudoBundle extends ResourceBundle { public static boolean isEnabled() { return (getMode() != BundleMode.NO_TRANSLATION); } PseudoBundle(ResourceBundle baseBundle); static boolean isEnabled(); @Override Enumeration<String> getKeys(); }
PseudoBundle extends ResourceBundle { public static boolean isEnabled() { return (getMode() != BundleMode.NO_TRANSLATION); } PseudoBundle(ResourceBundle baseBundle); static boolean isEnabled(); @Override Enumeration<String> getKeys(); static final String PSEUDO_BUNDLE_PROPERTY; static final String PSEUDO_BUNDLE_NORMAL; static final String PSEUDO_BUNDLE_WIDE; }