Skip to content

Commit

Permalink
#1839 Added support for Chinese to React pages and fixed bug with imp…
Browse files Browse the repository at this point in the history
…orting localization messages that use UTF-8 characters
  • Loading branch information
jmiranda committed Nov 1, 2020
1 parent 97fb170 commit 9c12999
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ package org.pih.warehouse.core

import org.springframework.web.multipart.MultipartFile

import java.nio.charset.Charset

class LocalizationController {

static allowedMethods = [save: "POST", update: "POST", delete: "POST", upload: "POST"]
Expand Down Expand Up @@ -142,7 +144,7 @@ class LocalizationController {
redirect(action: "list", id: params.id)
}
} else {
flash.message = "${warehouse.message(code: 'default.not.found.message', args: [warehouse.message(code: 'localization.label', default: 'Localization'), params.id])}"
flash.message = "${warehouse.message(code: 'default.not.found.message', args: [warehouse.message(code: 'localization.label', default: 'Localization'), params.id])}"
redirect(action: "list")
}
}
Expand Down Expand Up @@ -173,7 +175,7 @@ class LocalizationController {

if (command.validate() && !command.hasErrors()) {
Properties properties = new Properties()
properties.load(command.messageProperties.inputStream)
properties.load(new InputStreamReader(command.messageProperties.inputStream, Charset.forName("UTF-8")));
properties.stringPropertyNames().each { String property ->
String text = properties.getProperty(property)
log.info "Property " + property + " = " + text
Expand All @@ -182,7 +184,7 @@ class LocalizationController {
localization = new Localization(code: property, locale: command.locale.language, text: text)
}
localization.text = text
localization.save(flush: true)
localization.save()

}
flash.message = "${warehouse.message(code: 'default.uploaded.message', args: [warehouse.message(code: 'localizations.label')])}"
Expand Down

0 comments on commit 9c12999

Please sign in to comment.