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 Aug 14, 2020
1 parent 317983b commit 3204fb8
Show file tree
Hide file tree
Showing 2 changed files with 7 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
2 changes: 2 additions & 0 deletions src/js/MainRouter.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class MainRouter extends React.Component {
{ name: 'Spanish', code: 'es' },
{ name: 'Finnish', code: 'fi' },
{ name: 'Portuguese', code: 'pt' },
{ name: 'Chinese', code: 'zh' },
],
options: {
renderToStaticMarkup,
Expand All @@ -43,6 +44,7 @@ class MainRouter extends React.Component {
this.props.addTranslationForLanguage(en, 'de');
this.props.addTranslationForLanguage(ar, 'ar');
this.props.addTranslationForLanguage(en, 'fi');
this.props.addTranslationForLanguage(en, 'zh');
}

componentDidMount() {
Expand Down

0 comments on commit 3204fb8

Please sign in to comment.