chore: 🤖 use new register and waitLocale methods

This commit is contained in:
Christian Kaisermann 2019-11-20 02:09:27 -03:00
parent bd2b3501e9
commit 3dce407f4f
4 changed files with 13 additions and 13 deletions

View File

@ -22,9 +22,9 @@
## TODO - WIP
- [ ] Maybe locale can be a promise so we can await for it on the template;
- [x] Maybe locale can be a promise so we can await for it on the template;
- [ ] Wiki on github;
- [ ] Find a more flexible way to preload dictionaries so it's possible to preload partial dictionaries.
- [x] Find a more flexible way to preload dictionaries so it's possible to preload partial dictionaries.
## Usage

View File

@ -1,6 +1,6 @@
import { registerLocaleLoader } from 'svelte-i18n'
import { register } from 'svelte-i18n'
registerLocaleLoader('en', () => import('../messages/en.json'))
registerLocaleLoader('pt-BR', () => import('../messages/pt-BR.json'))
registerLocaleLoader('en-US', () => import('../messages/en-US.json'))
registerLocaleLoader('es-ES', () => import('../messages/es-ES.json'))
register('en', () => import('../messages/en.json'))
register('pt-BR', () => import('../messages/pt-BR.json'))
register('en-US', () => import('../messages/en-US.json'))
register('es-ES', () => import('../messages/es-ES.json'))

View File

@ -1,5 +1,5 @@
<script context="module">
import { locale, locales, getClientLocale } from 'svelte-i18n'
import { locale, locales, getClientLocale, waitLocale } from 'svelte-i18n'
import Lang from 'svelte-i18n/Lang.svelte'
export async function preload() {

View File

@ -1,12 +1,12 @@
<script context="module">
import { registerLocaleLoader, flushLocaleQueue } from 'svelte-i18n'
import { register, waitLocale } from 'svelte-i18n'
registerLocaleLoader('en-US', () => import('./_locales/en-US.json'))
registerLocaleLoader('pt-BR', () => import('./_locales/pt-BR.json'))
registerLocaleLoader('es-ES', () => import('./_locales/es-ES.json'))
register('en-US', () => import('./_locales/en-US.json'))
register('pt-BR', () => import('./_locales/pt-BR.json'))
register('es-ES', () => import('./_locales/es-ES.json'))
export async function preload() {
return flushLocaleQueue()
return waitLocale()
}
</script>