forked from dcloudio/uni-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
485 additions
and
284 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"uni.showActionSheet.cancel": "cancel", | ||
"uni.showToast.unpaired": "Please note showToast must be paired with hideToast", | ||
"uni.showLoading.unpaired": "Please note showLoading must be paired with hideLoading", | ||
"uni.showModal.cancel": "cancel", | ||
"uni.showModal.confirm": "confirm", | ||
"uni.button.feedback.title": "feedback", | ||
"uni.button.feedback.send": "send" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"uni.showActionSheet.cancel": "cancelar", | ||
"uni.showToast.unpaired": "Tenga en cuenta que showToast debe estar emparejado con hideToast", | ||
"uni.showLoading.unpaired": "Tenga en cuenta que showLoading debe estar emparejado con hideLoading", | ||
"uni.showModal.cancel": "cancelar", | ||
"uni.showModal.confirm": "confirmar", | ||
"uni.button.feedback.title": "realimentación", | ||
"uni.button.feedback.send": "enviar" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"uni.showActionSheet.cancel": "Annuler", | ||
"uni.showToast.unpaired": "Veuillez noter que showToast doit être associé à hideToast", | ||
"uni.showLoading.unpaired": "Veuillez noter que showLoading doit être associé à hideLoading", | ||
"uni.showModal.cancel": "Annuler", | ||
"uni.showModal.confirm": "confirmer", | ||
"uni.button.feedback.title": "retour d'information", | ||
"uni.button.feedback.send": "envoyer" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import i18n from '@dcloudio/uni-i18n' | ||
|
||
import en from './en.json' | ||
import es from './es.json' | ||
import fr from './fr.json' | ||
import zhHans from './zh-Hans.json' | ||
import zhHant from './zh-Hant.json' | ||
|
||
const messages = { | ||
en, | ||
es, | ||
fr, | ||
'zh-Hans': zhHans, | ||
'zh-Hant': zhHant | ||
} | ||
|
||
const fallbackLocale = 'en' | ||
|
||
export function initI18n (locale, onChange) { | ||
i18n.init({ | ||
locale, | ||
fallbackLocale, | ||
messages | ||
}) | ||
if (onChange) { | ||
i18n.watchLocale((newLocale, oldLocale) => { | ||
onChange(newLocale, oldLocale) | ||
}) | ||
} | ||
} | ||
|
||
function initLocaleWatcher (app) { | ||
app.$i18n.vm.$watch('locale', (newLocale) => { | ||
i18n.setLocale(newLocale) | ||
}, { | ||
immediate: true | ||
}) | ||
} | ||
|
||
export function t (key, values) { | ||
if (__VIEW__) { | ||
return i18n.t(key, values) | ||
} | ||
const app = getApp() | ||
if (!app.$t) { | ||
/* eslint-disable no-func-assign */ | ||
t = function (key, values) { | ||
return i18n.t(key, values) | ||
} | ||
} else { | ||
initLocaleWatcher(app) | ||
/* eslint-disable no-func-assign */ | ||
t = function (key, values) { | ||
const $i18n = app.$i18n | ||
const silentTranslationWarn = $i18n.silentTranslationWarn | ||
$i18n.silentTranslationWarn = true | ||
const msg = app.$t(key, values) | ||
$i18n.silentTranslationWarn = silentTranslationWarn | ||
if (msg !== key) { | ||
return msg | ||
} | ||
return i18n.t(key, values) | ||
} | ||
} | ||
return t(key, values) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"uni.showActionSheet.cancel": "取消", | ||
"uni.showToast.unpaired": "请注意 showToast 与 hideToast 必须配对使用", | ||
"uni.showLoading.unpaired": "请注意 showLoading 与 hideLoading 必须配对使用", | ||
"uni.showModal.cancel": "取消", | ||
"uni.showModal.confirm": "确认", | ||
"uni.button.feedback.title": "问题反馈", | ||
"uni.button.feedback.send": "发送" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"uni.showActionSheet.cancel": "取消", | ||
"uni.showToast.unpaired": "請注意 showToast 與 hideToast 必須配對使用", | ||
"uni.showLoading.unpaired": "請注意 showLoading 與 hideLoading 必須配對使用", | ||
"uni.showModal.cancel": "取消", | ||
"uni.showModal.confirm": "確認", | ||
"uni.button.feedback.title": "問題反饋", | ||
"uni.button.feedback.send": "發送" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.