Skip to content

Commit

Permalink
feat: Refactor i18n setup to use async function for locale registration
Browse files Browse the repository at this point in the history
  • Loading branch information
Ahmedhossamdev committed Nov 20, 2024
1 parent 52ac2d6 commit 1327317
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions src/lib/i18n.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
import { init, register, getLocaleFromNavigator } from 'svelte-i18n';

register('en', () => import('./../locales/en.json')); // English
register('es', () => import('./../locales/es.json')); // Spanish
register('pl', () => import('./../locales/pl.json')); // Polish
register('vi', () => import('./../locales/vi.json')); // Vietnamese
register('tl', () => import('./../locales/tl.json')); // Tagalog
register('so', () => import('./../locales/so.json')); // Somali
register('am', () => import('./../locales/am.json')); // Amharic
register('ar', () => import('./../locales/ar.json')); // Arabic
async function setup() {
register('en', () => import('./../locales/en.json')); // English
register('es', () => import('./../locales/es.json')); // Spanish
register('pl', () => import('./../locales/pl.json')); // Polish
register('vi', () => import('./../locales/vi.json')); // Vietnamese
register('tl', () => import('./../locales/tl.json')); // Tagalog
register('so', () => import('./../locales/so.json')); // Somali
register('am', () => import('./../locales/am.json')); // Amharic
register('ar', () => import('./../locales/ar.json')); // Arabic

init({
fallbackLocale: 'en',
initialLocale: getLocaleFromNavigator()
});
return await Promise.allSettled([
init({
fallbackLocale: 'en',
initialLocale: getLocaleFromNavigator()
})
]);
}

await setup();

0 comments on commit 1327317

Please sign in to comment.