Skip to content

Commit

Permalink
Merge pull request #209 from shoito/add-japanese-language-support
Browse files Browse the repository at this point in the history
Add Japanese language support
  • Loading branch information
clun committed Mar 26, 2017
2 parents 812ef15 + 24be6a6 commit 1a10f2c
Show file tree
Hide file tree
Showing 4 changed files with 204 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@

import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.text.MessageFormat;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.Properties;

import org.ff4j.web.bean.WebConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.thymeleaf.Arguments;
Expand Down Expand Up @@ -66,17 +68,22 @@ public CustomMessageResolver() {
}

/** {@inheritDoc} */
public void initialize() {
try {
defaultMessages.load(
CustomMessageResolver.class.getClassLoader()
.getResourceAsStream(MSG_FILE + MSG_FILE_EXTENSION));
} catch (IOException e) {
LOGGER.error("Cannot load properties", e);
}
}

/**
public void initialize() {
InputStream is = null;
InputStreamReader r = null;
try {
is = CustomMessageResolver.class.getClassLoader().getResourceAsStream(MSG_FILE + MSG_FILE_EXTENSION);
r = new InputStreamReader(is, WebConstants.UTF8_ENCODING);
defaultMessages.load(r);
} catch (IOException e) {
LOGGER.error("Cannot load properties", e);
} finally {
if (r != null) try { r.close(); } catch (IOException e) {}
if (is != null) try { is.close(); } catch (IOException e) {}
}
}

/**
* Load property file from locale and put in cache.
*
* @param locale
Expand All @@ -86,18 +93,24 @@ public void initialize() {
*/
private Properties resolveProperties(Locale locale) {
if (!messages.containsKey(locale.getLanguage())) {
String expectedFileName = MSG_FILE + "_" + locale.getLanguage() + MSG_FILE_EXTENSION;
InputStream is = CustomMessageResolver.class.getClassLoader().getResourceAsStream(expectedFileName);
messages.put(locale.getLanguage(), null);

String expectedFileName = MSG_FILE + "_" + locale.getLanguage() + MSG_FILE_EXTENSION;
InputStream is = CustomMessageResolver.class.getClassLoader().getResourceAsStream(expectedFileName);
InputStreamReader r = null;
if (is != null) {
try {
r = new InputStreamReader(is, WebConstants.UTF8_ENCODING);
Properties propsLocale = new Properties();
propsLocale.load(is);
propsLocale.load(r);
messages.put(locale.getLanguage(), propsLocale);
} catch (IOException e) {
LOGGER.error("Cannot load properties", e);
}
}
} finally {
if (r != null) try { r.close(); } catch (IOException e) {}
if (is != null) try { is.close(); } catch (IOException e) {}
}
}
}
Properties target = messages.get(locale.getLanguage());
return target != null ? target : defaultMessages;
Expand Down
171 changes: 171 additions & 0 deletions ff4j-web/src/main/resources/ff4j-messages_ja.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@

# ----------------- #
# NAVBARS #
# ----------------- #
navbar.title=管理コンソール

# Navbar of home page
navbar.main.home=ホーム
navbar.main.features=機能
navbar.main.properties=プロパティ
navbar.main.supervision=モニタリング
navbar.main.settings=設定
navbar.main.uptime=Uptime
navbar.main.back=戻る
navbar.main.refresh=更新
navbar.main.about=FF4Jについて

# Navbar of feature page
navbar.feature.new=新規
navbar.feature.copy=コピー
navbar.feature.rename=名前の変更
navbar.feature.togglegroup=トグルグループ

# Navbar of property page
navbar.property.new=新規
navbar.property.copy=コピー
navbar.property.rename=名前の変更

# -----------------
# View :: Home
# -----------------
home.general.title=概要
home.general.version=バージョン
home.store.undefined=未使用
home.admin.title=管理
home.admin.importXML=XMLインポート
home.admin.exportXML=XMLエクスポート
home.admin.createSchema=スキーマ作成

modal.importxml.title=機能とプロパティのインポート
modal.importxml.desc=機能とプロパティが定義されたXMLファイルを選択してください
modal.createschema.title=スキーマ作成
modal.createschema.message=データストアにスキーマを作成しますか? 既にスキーマがある場合、何も起こりません。

# ----------------- #
# View Properties #
# ----------------- #
property.title=プロパティリスト
property.table.name=ID
property.table.value=
property.table.type=データ型
property.table.fixedValue=固定値

# ----------------- #
# View Features #
# ----------------- #
feature.title=機能リスト
feature.table.name=ID
feature.table.group=グループ
feature.table.role=ロール
feature.table.strategy=ストラテジー
feature.table.toggle=トグル
feature.table.properties=プロパティ
feature.table.edit=E
feature.table.supp=S

# ----------------- #
# - View Infoq #
# ----------------- #
infos.techs.title=マネージドテクノロジー
infos.donation.title=ご支援ください!
infos.contact.title=問い合わせ

# ----------------- #
# - View 404 #
# ----------------- #
404.title=ここには何もありません!
404.subtitle=探しているページが見つかりませんでした。
404.back=ホームに戻る

modal.button.validate=適用
modal.button.cancel=キャンセル
modal.button.create=作成
modal.button.delete=削除

#---------------------------
#- MODAL CREATE FEATURE -
#---------------------------
modal.createfeature.title=新しい機能
modal.createfeature.featurename=機能名
modal.createfeature.description=詳細
modal.createfeature.comment=機能を作成してから、全ての属性を設定できます

#---------------------------
# MODAL EDIT FEATURE
#---------------------------
modal.editfeature.title=機能の更新
modal.editfeature.group=グループ
modal.editfeature.strategy=ストラテジー
modal.editfeature.permissions=権限

#---------------------------
# MODAL RENAME FEATURE
#---------------------------
modal.renamefeature.title=機能名の変更
modal.renamefeature.list=機能リスト
modal.renamefeature.new=新しい名前

#---------------------------
# MODAL DELETE FEATURE
#---------------------------
modal.deletefeature.title=機能の削除
modal.deletefeature.confirmMessage=この機能を削除してもよろしいですか?

#---------------------------
# MODAL DELETE PROPERTY
#---------------------------
modal.deleteproperty.title=プロパティの削除
modal.deleteproperty.confirmMessage=このプロパティを削除してもよろしいですか?

#---------------------------
# MODAL COPY FEATURE
#---------------------------
modal.copyfeature.title=機能のコピー
modal.copyfeature.list=機能リスト
modal.copyfeature.new=新しい名前

#---------------------------
# MODAL COPY FEATURE
#---------------------------
modal.copyproperty.title=プロパティのコピー
modal.copyproperty.list=プロパティリスト
modal.copyproperty.new=新しい名前

#---------------------------
# MODAL RENAME PROPERTY
#---------------------------
modal.renameproperty.title=プロパティ名の変更
modal.renameproperty.list=プロパティリスト
modal.renameproperty.new=新しい名前


#---------------------------
# MODAL RENAME PROPERTY
#---------------------------
modal.togglegroup.title=グループの有効化/無効化
modal.togglegroup.list=グループリスト
modal.togglegroup.operation=操作

#---------------------------
#-- MODAL CREATE PROPERTY --
#---------------------------
modal.createproperty.title=プロパティの作成
modal.createproperty.featureid=機能名
modal.createproperty.propertyname=プロパティ名
modal.createproperty.description=説明
modal.createproperty.type=データ型
modal.createproperty.value=
modal.createproperty.comment=プロパティを作成してから、固定値を編集できます

#---------------------------
#-- MODAL UPDATE PROPERTY --
#---------------------------
modal.editproperty.title=プロパティの変更
modal.editproperty.featureid=機能名
modal.editproperty.propertyname=プロパティ名
modal.editproperty.description=説明
modal.editproperty.type=データ型
modal.editproperty.value=
modal.editproperty.fixedValues=固定値

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions ff4j-web/src/main/resources/views/view-navbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
<span th:if="${#locale.language == 'de'}">
<img src="" th:src="@{static/img/flags/flagGermany.png}" style="height:20px" />
</span>
<span th:if="${#locale.language == 'ja'}">
<img src="" th:src="@{static/img/flags/flagJapanese.png}" style="height:20px" />
</span>
<span th:text="${#locale.language}">locale</span>
<b class="caret"></b>
</a>
Expand All @@ -39,6 +42,7 @@
<li><a href="?lang=en"><img src="" th:src="@{static/img/flags/flagEnglish.png}" style="height:15px" />&nbsp;English</a></li>
<li><a href="?lang=fr"><img src="" th:src="@{static/img/flags/flagFrance.png}" style="height:15px" />&nbsp;Français</a></li>
<li><a href="?lang=de"><img src="" th:src="@{static/img/flags/flagGermany.png}" style="height:15px" />&nbsp;Deutsch</a></li>
<li><a href="?lang=ja"><img src="" th:src="@{static/img/flags/flagJapanese.png}" style="height:15px" />&nbsp;Japanese</a></li>
</ul>

</li>
Expand Down

0 comments on commit 1a10f2c

Please sign in to comment.