### Question:
HapiLocalizer { MessageFormat newMessageFormat(String theFormatString) { StringBuilder pattern = new StringBuilder(theFormatString.trim()); for (int i = 0; i < (pattern.length()-1); i++) { if (pattern.charAt(i) == '{') { char nextChar = pattern.charAt(i+1); if (nextChar >= '0' && nextChar <= '9') { continue; } pattern.replace(i, i+1, "'{'"); int closeBraceIndex = pattern.indexOf("}", i); if (closeBraceIndex > 0) { i = closeBraceIndex; pattern.replace(i, i+1, "'}'"); } } } return new MessageFormat(pattern.toString()); } HapiLocalizer();  HapiLocalizer(String... theBundleNames); Set<String> getAllKeys(); @SuppressWarnings("WeakerAccess") String getFormatString(String theQualifiedKey); String getMessage(Class<?> theType, String theKey, Object... theParameters); String getMessageSanitized(Class<?> theType, String theKey, Object... theParameters); String getMessage(String theQualifiedKey, Object... theParameters); Locale getLocale(); static void setOurFailOnMissingMessage(boolean ourFailOnMissingMessage); static String toKey(Class<?> theType, String theKey); @SuppressWarnings("WeakerAccess")
	static final String UNKNOWN_I18N_KEY_MESSAGE; }### Answer:
@Test public void testEscapePatterns() { HapiLocalizer loc = new HapiLocalizer(); assertEquals("some message", loc.newMessageFormat("some message").format(new Object[]{})); assertEquals("var1 {var2} var3 {var4}", loc.newMessageFormat("var1 {var2} var3 {var4}").format(new Object[]{})); assertEquals("var1 A var3 B", loc.newMessageFormat("var1 {0} var3 {1}").format(new Object[]{ "A", "B"})); }