Skip to content

Commit

Permalink
feat: [plugin-local] 添加 getLocal API 获取当前用户选择的语言
Browse files Browse the repository at this point in the history
  • Loading branch information
winixt committed Jan 23, 2024
1 parent 03fba1a commit 8cfa16b
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/fes-plugin-locale/src/runtime/core.js.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ const setLocale = ({ locale }) => {
window.localStorage.setItem("fes_locale", locale);
};

const getLocale = () => {
return unref(i18n.global.locale)
}

const addLocale = ({ locale, messages }) => {
messages[locale] = messages;
if (isRef(i18n.global.messages)) {
Expand All @@ -82,6 +86,7 @@ const t = (key) => {

const locale = {
setLocale,
getLocale,
addLocale,
getAllLocales,
messages,
Expand Down

0 comments on commit 8cfa16b

Please sign in to comment.