Search in sources :

Example 1 with I18nOutput

use of org.hisp.dhis.webapi.webdomain.i18n.I18nOutput in project dhis2-core by dhis2.

the class I18nController method postI18n.

@PostMapping
@ResponseBody
public I18nOutput postI18n(@RequestParam(value = "package", required = false, defaultValue = "org.hisp.dhis") String searchPackage, HttpServletResponse response, InputStream inputStream) throws Exception {
    I18n i18n = i18nManager.getI18n(searchPackage);
    I18nOutput output = new I18nOutput();
    I18nInput input = jsonMapper.readValue(inputStream, I18nInput.class);
    for (String key : input) {
        String value = i18n.getString(key);
        if (value != null) {
            output.getTranslations().put(key, value);
        }
    }
    response.setContentType(MediaType.APPLICATION_JSON_VALUE);
    return output;
}
Also used : I18nOutput(org.hisp.dhis.webapi.webdomain.i18n.I18nOutput) I18nInput(org.hisp.dhis.webapi.webdomain.i18n.I18nInput) I18n(org.hisp.dhis.i18n.I18n) PostMapping(org.springframework.web.bind.annotation.PostMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

I18n (org.hisp.dhis.i18n.I18n)1 I18nInput (org.hisp.dhis.webapi.webdomain.i18n.I18nInput)1 I18nOutput (org.hisp.dhis.webapi.webdomain.i18n.I18nOutput)1 PostMapping (org.springframework.web.bind.annotation.PostMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1