Skip to content

Commit

Permalink
feat: add i18n option
Browse files Browse the repository at this point in the history
  • Loading branch information
altrusl committed Jan 3, 2024
1 parent ff633d7 commit 899a3cb
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/composables/useI18nLight.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const locales: Locale[] = [
];

const locale: Ref<Locale> = ref();
const messages = {
const messages: Record<string, object> = {
en: enLocale,
es: esLocale,
};
Expand All @@ -38,14 +38,14 @@ export function useI18n() {
}

// It can load locales from remote server
async function setLocale(code) {
if (locale.value !== code) {
async function setLocale(code: string) {
if (locale.value.code !== code) {
locale.value = locales.find(l => l.code === code);
localStorage.setItem("vue-webapp_lang", locale.value.code);
}
}

function t(msg, params = null) {
function t(msg: string, params: Record<string, string> = null) {
if (!msg || !locale.value) {
return "";
}
Expand Down

0 comments on commit 899a3cb

Please sign in to comment.