Skip to content

Commit

Permalink
Merge pull request #156 from OneBusAway/safari-fix
Browse files Browse the repository at this point in the history
Disable top-level await to fix the site in Safari
  • Loading branch information
aaronbrethorst authored Dec 19, 2024
2 parents 9530044 + 2295c21 commit 45095be
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 23 deletions.
39 changes: 21 additions & 18 deletions src/lib/i18n.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
import { init, register, getLocaleFromNavigator } from 'svelte-i18n';
import { init, addMessages, getLocaleFromNavigator } from 'svelte-i18n';

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
import amharic from '../locales/am.json';
import arabic from '../locales/ar.json';
import english from '../locales/en.json';
import spanish from '../locales/es.json';
import polish from '../locales/pl.json';
import somali from '../locales/so.json';
import tagalog from '../locales/tl.json';
import vietnamese from '../locales/vi.json';

return await Promise.allSettled([
init({
fallbackLocale: 'en',
initialLocale: getLocaleFromNavigator()
})
]);
}
addMessages('am', amharic);
addMessages('ar', arabic);
addMessages('en', english);
addMessages('es', spanish);
addMessages('pl', polish);
addMessages('so', somali);
addMessages('tl', tagalog);
addMessages('vi', vietnamese);

await setup();
init({
fallbackLocale: 'en',
initialLocale: getLocaleFromNavigator()
});
5 changes: 0 additions & 5 deletions vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,5 @@ export default defineConfig({
plugins: [sveltekit()],
test: {
include: ['src/**/*.{test,spec}.{js,ts}']
},
esbuild: {
supported: {
'top-level-await': true
}
}
});

0 comments on commit 45095be

Please sign in to comment.