Search in sources :

Example 1 with JsonResourceBundle

use of com.tyndalehouse.step.rest.framework.JsonResourceBundle in project step by STEPBible.

the class InternationalJsonController method readBundle.

/**
 * Read bundle.
 *
 * @param locale the locale
 * @return the string
 */
private String readBundle(final Locale locale, final String... bundleNames) {
    List<ResourceBundle> bundles = new ArrayList<ResourceBundle>(bundleNames.length);
    for (String b : bundleNames) {
        bundles.add(ResourceBundle.getBundle(b, locale));
    }
    final JsonResourceBundle jsonResourceBundle = new JsonResourceBundle(bundles);
    String jsonResponse;
    try {
        jsonResponse = objectMapper.writeValueAsString(jsonResourceBundle);
    } catch (final IOException e) {
        throw new StepInternalException("Unable to read messages", e);
    }
    return "var __s = " + jsonResponse;
}
Also used : JsonResourceBundle(com.tyndalehouse.step.rest.framework.JsonResourceBundle) StepInternalException(com.tyndalehouse.step.core.exceptions.StepInternalException) JsonResourceBundle(com.tyndalehouse.step.rest.framework.JsonResourceBundle) IOException(java.io.IOException)

Aggregations

StepInternalException (com.tyndalehouse.step.core.exceptions.StepInternalException)1 JsonResourceBundle (com.tyndalehouse.step.rest.framework.JsonResourceBundle)1 IOException (java.io.IOException)1