Open clonn opened 9 years ago
h3. 一 執行模組設定
路徑 : /assets/linker/ js/ ... 檔案名稱 : app.coffee / server.coffee (前端的Router)
注入 pascalprecht.translate:
app = angular.module("admgmtApp", ["xxx",...., "pascalprecht.translate"])
設定 :
app.config ["$translateProvider", ($translateProvider) -> $translateProvider.useStaticFilesLoader { prefix: '/locales/' suffix: '.json' } $translateProvider.preferredLanguage('us') ]
h3. 二 關於josn檔
路徑:/config/locals/xxx.json
EX :
"kpi-form-lab-kpiname": "adCreative KPI Name", "kpi-form-ph-kpiname": "KPI Name", "kpi-form-invalid-kpiname": "Please enter KPI name",
PS. lab = input前的題詞, desc = 其他更長的敘述
"kpi-list-name": "KPI Name",
"signup-password": "Password",
頁面功能-區域性-元素/值, 頁面功能-相關值 EX :
"landing-content-header": "AdManagement Dashboard", "landing-content-ad_create": "Create adCampaign",
h3. 三. 頁面使用方式
#{__("global-footer-tw")}
{{ 'adS-bid-info_price' | translate }}
PS. html裡面也可以使用, 要注意雙引和單引的位置 EX:
placeholder = "{{ 'adS-bid-info_price' | translate }}"
h3. 四. 資料來源於controllers(可參考附件二)
直接舉例 : 在畫面上的code :
" {{tabs[0].title}} "
在controller裡面的code :
angular.module("admgmtApp").controller "adSetCtrl", ($scope, .... $translate) ->
$translate(["adSet_budget_tab_daily", "adSet_budget_tab_lifetime"]).then (translations) -> $scope.tabs = [ { title: translations.adSet_budget_tab_daily, active: true} { title: translations.adSet_budget_tab_lifetime, active: false} ]
$translate("adSet_budget_tab_daily").then (value) -> $scope.tabs = [ { title: value, active: true} { title: value, active: false} ]
bq. p.s. 在controller裡面用的值不能使用hyphen("-"),config/locales/裡的檔案們,相對應的值也要一併作更改。 Ex:
$translate("aaa_bbb")
O:aaa_bbb X:aaa-bbb
參考文件 : 附件一:https://github.com/nodejs-tw/nodejs-book-beginner-guide/blob/master/sailsjs/i18n.md 附件二:http://angular-translate.github.io/docs/#/guide/03_using-translate-service
develop tool : Live Reload https://chrome.google.com/webstore/detail/livereload/jnihajbhpnppcggbcgedagnkighmdlei?utm_source=chrome-ntp-icon
h3. 一 執行模組設定
路徑 : /assets/linker/ js/ ... 檔案名稱 : app.coffee / server.coffee (前端的Router)
注入 pascalprecht.translate:
設定 :
h3. 二 關於josn檔
路徑:/config/locals/xxx.json
EX :
PS. lab = input前的題詞, desc = 其他更長的敘述
頁面功能-區域性-元素/值, 頁面功能-相關值 EX :
h3. 三. 頁面使用方式
PS. html裡面也可以使用, 要注意雙引和單引的位置 EX:
h3. 四. 資料來源於controllers(可參考附件二)
直接舉例 : 在畫面上的code :
在controller裡面的code :
多筆key值用array的方式丟進去會回傳 object
單筆key值用string的方式會回傳對應的string
bq. p.s. 在controller裡面用的值不能使用hyphen("-"),config/locales/裡的檔案們,相對應的值也要一併作更改。 Ex:
O:aaa_bbb X:aaa-bbb
參考文件 : 附件一:https://github.com/nodejs-tw/nodejs-book-beginner-guide/blob/master/sailsjs/i18n.md 附件二:http://angular-translate.github.io/docs/#/guide/03_using-translate-service
develop tool : Live Reload https://chrome.google.com/webstore/detail/livereload/jnihajbhpnppcggbcgedagnkighmdlei?utm_source=chrome-ntp-icon