Sotaro KARASAWA 9 years ago
parent
commit
77d5908f96

+ 2 - 1
lib/crowi/express-init.js

@@ -30,7 +30,8 @@ module.exports = function(crowi, app) {
     .use(i18nFsBackend)
     .use(i18nSprintf)
     .init({
-      fallbackLng: User.LANG_EN_US,
+      debug: true,
+      fallbackLng: [User.LANG_EN_US],
       whitelist: Object.keys(User.getLanguageLabels()).map((k) => User[k]),
       backend: {
         loadPath: 'locales/{{lng}}/translation.json'

+ 1 - 0
lib/crowi/index.js

@@ -23,6 +23,7 @@ function Crowi (rootdir, env)
   this.publicDir = path.join(this.rootDir, 'public') + sep;
   this.libDir    = path.join(this.rootDir, 'lib') + sep;
   this.eventsDir = path.join(this.libDir, 'events') + sep;
+  this.localeDir = path.join(this.rootDir, 'locales') + sep;
   this.resourceDir = path.join(this.rootDir, 'resource') + sep;
   this.viewsDir  = path.join(this.libDir, 'views') + sep;
   this.mailDir   = path.join(this.viewsDir, 'mail') + sep;

+ 4 - 4
lib/models/user.js

@@ -13,9 +13,9 @@ module.exports = function(crowi) {
     , STATUS_INVITED    = 5
     , USER_PUBLIC_FIELDS = '_id image googleId name username email introduction status createdAt admin' // TODO: どこか別の場所へ...
 
-    , LANG_EN_US = 'en_US'
-    , LANG_EN_GB = 'en_GB'
-    , LANG_JA_JP = 'ja_JP'
+    , LANG_EN_US = 'en-US'
+    , LANG_EN_GB = 'en-GB'
+    , LANG_JA_JP = 'ja'
 
     , PAGE_ITEMS        = 50
 
@@ -96,7 +96,7 @@ module.exports = function(crowi) {
   function getLanguageLabels() {
     var lang = {};
     lang.LANG_EN_US = LANG_EN_US;
-    lang.LANG_JA_JP = LANG_EN_US;
+    lang.LANG_JA_JP = LANG_JA_JP;
 
     return lang;
   }

+ 2 - 2
lib/util/i18nUserSettingDetector.js

@@ -2,11 +2,11 @@ module.exports = {
   name: 'userSettingDetector',
 
   lookup: function(req, res, options) {
-    var lang;
+    var lang = null;
 
     if (req.user) {
       if ('lang' in req.user) {
-        lang = req.user.lang;
+        lang = req.user.lang || null;
       }
     }
 

+ 1 - 1
lib/views/layout/layout.html

@@ -75,7 +75,7 @@
       #}
       <li id="" class="dropdown">
         <button class="btn btn-default create-page-button" data-target="#create-page" data-toggle="modal">
-          <i class="fa fa-pencil"></i> {{ t('Create') }}
+          <i class="fa fa-pencil"></i> {{ t('New') }}
         </button>
       </li>
       <li id="login-user">

+ 7 - 7
lib/views/login.html

@@ -79,8 +79,8 @@
 
     {% if config.crowi['security:registrationMode'] == 'Restricted' %}
     <p class="alert alert-warning">
-      {{ t('New registration to this wiki is restricted') }}<br>
-      {{ t('In order to start using it, approval by the administrator is necessary after new registration') }}
+      {{ t('page_register.notice.restricted') }}<br>
+      {{ t('page_register.notice.restricted_defail') }}
     </p>
     {% endif %}
 
@@ -91,8 +91,8 @@
         <img src="{{ googleImage }}" class="picture picture-rounded picture-lg">
       </p>
       {% endif %}
-      <code>{{ googleEmail }}</code> {{ t('Register with this Google Account') }}<br>
-      {{ t('Please decide user ID, name and password and continue registration') }}
+      <code>{{ googleEmail }}</code> {{ t('page_register with this Google Account') }}<br>
+      {{ t('page_register.notice.google_account_continue') }}
     </div>
     {% endif %}
 
@@ -143,7 +143,7 @@
       </div>
       {% if config.crowi['security:registrationWhiteList'] && config.crowi['security:registrationWhiteList'].length %}
       <p class="help-block">
-        {{ t('In this wiki, only the following e-mail address can be registered.') }}
+        {{ t('page_register.form_help.email') }}
       </p>
       <ul>
         {% for em in config.crowi['security:registrationWhiteList'] %}
@@ -158,7 +158,7 @@
         <input type="password" class="form-control" placeholder="Password" name="registerForm[password]" required>
       </div>
       <p class="help-block">
-        {{ t('Password format') }}
+        {{ t('page_register.form_help.password') }}
       </p>
 
       {% if googleImage %}
@@ -173,7 +173,7 @@
     <div class="row">
       {% if googleLoginEnabled() %}
       <div class="col-md-6">
-        <p>{{ t('Register by Google Account') }}</p>
+        <p>{{ t('page_register by Google Account') }}</p>
         <form role="form" method="post" action="/register/google">
           <input type="hidden" name="_csrf" value="{{ csrf() }}">
           <button type="submit" class="btn btn-block btn-google"><i class="fa fa-google-plus-square"></i> {{ t('Login') }}</button>

+ 2 - 2
lib/views/me/index.html

@@ -85,8 +85,8 @@
         <div class="form-group {% if not user.lang %}has-error{% endif %}">
           <label for="userForm[lang]" class="col-sm-2 control-label">{{ t('lang') }}</label>
           <div class="col-sm-4 radio">
-            <label><input type="radio" name="userForm[lang]" value="en" {% if user.lang == consts.LANG_EN_US %}checked="checked"{% endif %}>{{ t('English') }}</label>
-            <label><input type="radio" name="userForm[lang]" value="ja" {% if user.lang == consts.LANG_JA_JP %}checked="checked"{% endif %}>{{ t('Japanese') }}</label>
+            <label><input type="radio" name="userForm[lang]" value="{{ consts.language.LANG_EN_US }}" {% if user.lang == consts.language.LANG_EN_US %}checked="checked"{% endif %}>{{ t('English') }}</label>
+            <label><input type="radio" name="userForm[lang]" value="{{ consts.language.LANG_JA_JP }}" {% if user.lang == consts.language.LANG_JA_JP %}checked="checked"{% endif %}>{{ t('Japanese') }}</label>
           </div>
           <div class="col-sm-offset-2 col-sm-10">
           </div>

+ 2 - 2
lib/views/page.html

@@ -137,7 +137,7 @@
   {% endif %}
   {% if not page.isLatestRevision() %}
   <div class="alert alert-warning">
-    <strong>{{ t('Warning') }}: </strong> {{ t('This is not the current version.') }} <i class="fa fa-magic"></i> <a href="{{ page.path }}">{{ t('Show latest page') }}</a>
+    <strong>{{ t('Warning') }}: </strong> {{ t('page.notice.version') }} <i class="fa fa-magic"></i> <a href="{{ page.path }}">{{ t('Show latest') }}</a>
   </div>
   {% endif %}
 
@@ -202,7 +202,7 @@
   </div>
   {% endif %}
 
-  <div id="notifPageEdited" class="fk-notif fk-notif-danger"><i class="fa fa-exclamation-triangle"></i> <span class="edited-user"></span> {{ t('was edited this page') }} <a href="javascript:location.reload();"><i class="fa fa-angle-double-right"></i> {{ t('Read latest page') }}</a></div>
+  <div id="notifPageEdited" class="fk-notif fk-notif-danger"><i class="fa fa-exclamation-triangle"></i> <span class="edited-user"></span> {{ t('was edited this page') }} <a href="javascript:location.reload();"><i class="fa fa-angle-double-right"></i> {{ t('Load latest') }}</a></div>
 </div>
 
 {% block content_main_after %}

+ 1 - 1
lib/views/page_list.html

@@ -112,7 +112,7 @@
   <div class="tab-content">
   {% if page and not page.isLatestRevision() %}
   <div class="alert alert-warning">
-    <strong>{{ t('Warning') }}: </strong> {{ t('"This is not the current version.') }} <i class="fa fa-magic"></i> <a href="{{ page.path }}">最新のポータルを表示</a>
+    <strong>{{ t('Warning') }}: </strong> {{ t('page.notice.version') }} <i class="fa fa-magic"></i> <a href="{{ page.path }}">最新のポータルを表示</a>
   </div>
   {% endif %}
     <div class="tab-pane {% if not req.body.pageForm %}active{% endif %}" id="revision-body">

+ 1 - 0
locales/en

@@ -0,0 +1 @@
+en_US

+ 23 - 14
locales/en_US/translation.json → locales/en-US/translation.json

@@ -7,26 +7,38 @@
   "Like!": "Like!",
   "Viewer": "Viewer",
   "Cancel": "Cancel",
+  "Create": "Create",
+  "Admin": "Admin",
+  "New": "New",
 
   "Update": "Update",
   "Update Page": "Update Page",
   "Warning": "Warning",
 
   "Sign in": "Sign in",
-  "Sign up is here": "Sign up is here",
-  "Sign in is here": "Sign in is here",
+  "Sign up is here": "Sign up",
+  "Sign in is here": "Sign in",
   "Registration": "Registration",
   "Register by Google Account": "Register by Google Account",
   "Sign in by Google Account": "Sign in by Google Account",
   "Register with this Google Account": "Register with this Google Account",
-  "Please decide user ID, name and password and continue registration": "Please decide user ID, name and password and continue registration.",
   "Example": "Example",
   "Taro Yamada": "Taro Yamada",
-  "New registration to this wiki is restricted": "New registration to this wiki is restricted.",
-  "In order to start using it, approval by the administrator is necessary after new registration": "In order to start using it, approval by the administrator is necessary after new registration.",
 
-  "List View": "List View",
-  "Timeline View": "Timeline View",
+  "page_register": {
+    "notice": {
+      "restricted": "New registration to this wiki is restricted.",
+      "restricted_defail": "In order to start using it, approval by the administrator is necessary after new registration.",
+      "google_account_continue": "Please decide user ID, name and password and continue registration."
+    },
+    "form_help": {
+      "email": "In this wiki, only the following e-mail address can be registered.",
+      "password": "Please enter at least 6 letters, numbers, alphanumeric characters, symbols etc for password."
+    }
+  },
+
+  "List View": "List",
+  "Timeline View": "Timeline",
   "Presentation Mode": "Presentation Mode",
 
   "Created": "Created",
@@ -39,8 +51,6 @@
   "View this version": "View this version",
   "View diff": "View diff",
 
-  "Admin": "Admin",
-  "Create": "Create",
   "User ID": "User ID",
   "User Settings": "User Settings",
   "User Infomation": "User Infomation",
@@ -70,10 +80,8 @@
   "New password": "New password",
   "for check": "for check",
   "Please set a password": "Please set a password",
-  "Password format": "Please enter at least 6 letters, numbers, alphanumeric characters, symbols etc for password.",
   "You can login email and password": "You can login <code>%s</code> and password",
 
-  "In this wiki, only the following e-mail address can be registered.": "In this wiki, only the following e-mail address can be registered.",
   "With Google Connect, you can sign in with your Google Account.": "With Google Connect, you can sign in with your Google Account.",
   "In this wiki, the registrable mail address is limited.": "In this wiki, the registrable mail address is limited.",
   "Only Google Apps accounts with the following email addresses are connectable Google accounts:": "Only Google Apps accounts with the following email addresses are connectable Google accounts:",
@@ -111,8 +119,9 @@
   "Browsing of this page is restricted": "Browsing of this page is restricted",
   "Share link of this page": "Share link of this page",
 
-  "Show latest page": "Show latest page",
-  "Read latest page": "Read latest page",
+  "Show latest": "Show latest",
+  "Load latest": "Load latest",
   "was edited this page": "was edited this page.",
-  "This is not the current version.": "This is not the current version."
+
+  "page.notice.version": "This is not the current version."
 }

+ 19 - 10
locales/ja_JP/translation.json → locales/ja/translation.json

@@ -7,6 +7,9 @@
   "Like!": "いいね!",
   "Viewer": "見た人",
   "Cancel": "キャンセル",
+  "Create": "作成",
+  "Admin": "管理",
+  "New": "作成",
 
   "Update": "更新",
   "Update Page": "ページを更新",
@@ -19,11 +22,20 @@
   "Register by Google Account": "Google で登録",
   "Sign in by Google Account": "Google でログイン",
   "Register with this Google Account": "この Google アカウントで登録します",
-  "Please decide user ID, name and password and continue registration": "ユーザーID、名前、パスワードを決めて登録を継続してください。",
   "Example": "例",
   "Taro Yamada": "山田 太郎",
-  "New registration to this wiki is restricted": "この Wiki への新規登録は制限されています。",
-  "In order to start using it, approval by the administrator is necessary after new registration": "利用を開始するには、新規登録後、管理者による承認が必要です。",
+
+  "page_register": {
+    "notice": {
+       "restricted": "この Wiki への新規登録は制限されています。",
+       "restricted_defail": "利用を開始するには、新規登録後、管理者による承認が必要です。",
+       "google_account_continue": "ユーザーID、名前、パスワードを決めて登録を継続してください。"
+    },
+    "form_help": {
+      "email": "この Wiki では以下のメールアドレスのみ登録可能です。",
+      "password": "パスワードには、6文字以上の半角英数字または記号等を設定してください。"
+    }
+  },
 
   "List View": "リスト表示",
   "Timeline View": "タイムライン表示",
@@ -39,8 +51,6 @@
   "View this version": "このバージョンを見る",
   "View diff": "差分を見る",
 
-  "Admin": "管理",
-  "Create": "作成",
   "User ID": "ユーザーID",
   "User Settings": "ユーザー設定",
   "User Infomation": "ユーザー情報",
@@ -74,10 +84,8 @@
   "New password": "新しいパスワード",
   "for check": "(確認用)",
   "Please set a password": "パスワードを設定してください",
-  "Password format": "パスワードには、6文字以上の半角英数字または記号等を設定してください。",
   "You can login email and password": "<code>%s</code> と設定されたパスワードの組み合わせでログイン可能になります。",
 
-  "In this wiki, only the following e-mail address can be registered.": "この Wiki では以下のメールアドレスのみ登録可能です。",
   "API Setting": "API設定",
   "API Token Setting": "API Token設定",
   "Current API Token": "現在のAPI Token",
@@ -108,8 +116,9 @@
   "Browsing of this page is restricted": "このページの閲覧は制限されています",
   "Share link of this page": "このページの共有用URL",
 
-  "Show latest page": "最新のページを表示",
-  "Read latest page": "最新版を読み込む",
+  "Show latest": "最新のページを表示",
+  "Load latest": "最新版を読み込む",
   "was edited this page": "さんがこのページを編集しました。",
-  "This is not the current version.": "これは現在の版ではありません。"
+
+  "page.notice.version": "これは現在の版ではありません。"
 }