mirror of
https://github.com/cupcakearmy/svelte-i18n.git
synced 2024-06-30 18:54:49 +02:00
docs: add RTL to example (#61)
* Added RTL (arabic) language * changed home, about, contact words (update from native speaker)
This commit is contained in:
parent
141cac9586
commit
2a1bea5559
22
example/messages/ar.json
Normal file
22
example/messages/ar.json
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
{
|
||||||
|
"title": {
|
||||||
|
"index": "Sapper project template!"
|
||||||
|
},
|
||||||
|
"nav": {
|
||||||
|
"home": "الرئيسية",
|
||||||
|
"about": "من نحن",
|
||||||
|
"blog": "اتصل بنا"
|
||||||
|
},
|
||||||
|
"messages": {
|
||||||
|
"success": "عظيم",
|
||||||
|
"high_five": "خمسة",
|
||||||
|
"try_editing": "حاول تحرير هذا الملف (src/routes/index.svelte) لاختبار إعادة التحميل المباشر."
|
||||||
|
},
|
||||||
|
"languages": {
|
||||||
|
"en": "English",
|
||||||
|
"pt_BR": "Português",
|
||||||
|
"es_ES": "Espanol",
|
||||||
|
"ar": "عربى"
|
||||||
|
},
|
||||||
|
"direction": "rtl"
|
||||||
|
}
|
|
@ -13,8 +13,10 @@
|
||||||
"try_editing": "Try editing this file (src/routes/index.svelte) to test live reloading."
|
"try_editing": "Try editing this file (src/routes/index.svelte) to test live reloading."
|
||||||
},
|
},
|
||||||
"languages": {
|
"languages": {
|
||||||
"pt_BR": "Portugues",
|
|
||||||
"en": "English",
|
"en": "English",
|
||||||
"es_ES": "Spanish"
|
"pt_BR": "Português",
|
||||||
}
|
"es_ES": "Espanol",
|
||||||
|
"ar": "عربى"
|
||||||
|
},
|
||||||
|
"direction": "ltr"
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,8 +13,10 @@
|
||||||
"try_editing": " Intente editar este archivo (src/routes/index.svelte) para probar la recarga en vivo."
|
"try_editing": " Intente editar este archivo (src/routes/index.svelte) para probar la recarga en vivo."
|
||||||
},
|
},
|
||||||
"languages": {
|
"languages": {
|
||||||
"pt_BR": "Portugués",
|
"en": "English",
|
||||||
"en": "Ingles",
|
"pt_BR": "Português",
|
||||||
"es_ES": "Espanol"
|
"es_ES": "Espanol",
|
||||||
}
|
"ar": "عربى"
|
||||||
|
},
|
||||||
|
"direction": "ltr"
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,8 +13,10 @@
|
||||||
"try_editing": "Tente editar este arquivo (src/routes/index.svelte) para testar o recarregamento ao vivo."
|
"try_editing": "Tente editar este arquivo (src/routes/index.svelte) para testar o recarregamento ao vivo."
|
||||||
},
|
},
|
||||||
"languages": {
|
"languages": {
|
||||||
|
"en": "English",
|
||||||
"pt_BR": "Português",
|
"pt_BR": "Português",
|
||||||
"en": "Inglês",
|
"es_ES": "Espanol",
|
||||||
"es_ES": "Espanhol"
|
"ar": "عربى"
|
||||||
}
|
},
|
||||||
|
"direction": "ltr"
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,10 +51,14 @@
|
||||||
padding: 1em 0.5em;
|
padding: 1em 0.5em;
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
.rtl {
|
||||||
|
direction: rtl;
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<nav>
|
<nav class={$_('direction')}>
|
||||||
<ul>
|
<ul class={$_('direction')}>
|
||||||
<li>
|
<li>
|
||||||
<a class:selected={segment === undefined} href=".">{$_('nav.home')}</a>
|
<a class:selected={segment === undefined} href=".">{$_('nav.home')}</a>
|
||||||
</li>
|
</li>
|
||||||
|
@ -78,7 +82,7 @@
|
||||||
class:selected={$locale.includes(item)}
|
class:selected={$locale.includes(item)}
|
||||||
href={`#!${item}`}
|
href={`#!${item}`}
|
||||||
on:click={() => ($locale = item)}>
|
on:click={() => ($locale = item)}>
|
||||||
{item.replace('-', '_')}
|
{$_('languages.' + item.replace('-', '_'))}
|
||||||
</span>
|
</span>
|
||||||
</li>
|
</li>
|
||||||
{/each}
|
{/each}
|
||||||
|
|
|
@ -3,6 +3,7 @@ import { register, init, getLocaleFromNavigator } from 'svelte-i18n'
|
||||||
register('en', () => import('../messages/en.json'))
|
register('en', () => import('../messages/en.json'))
|
||||||
register('pt-BR', () => import('../messages/pt-BR.json'))
|
register('pt-BR', () => import('../messages/pt-BR.json'))
|
||||||
register('es-ES', () => import('../messages/es-ES.json'))
|
register('es-ES', () => import('../messages/es-ES.json'))
|
||||||
|
register('ar', () => import('../messages/ar.json'))
|
||||||
|
|
||||||
init({
|
init({
|
||||||
fallbackLocale: 'en',
|
fallbackLocale: 'en',
|
||||||
|
|
7
example/src/routes/about/_locales/ar.json
Normal file
7
example/src/routes/about/_locales/ar.json
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
"title": {
|
||||||
|
"about": "About"
|
||||||
|
},
|
||||||
|
"about_this_site": "عن هذا الموقع",
|
||||||
|
"about_content": ["هذه هي صفحة 'حول'. ليس هناك الكثير هنا."]
|
||||||
|
}
|
|
@ -4,6 +4,7 @@
|
||||||
register('en', () => import('./_locales/en.json'))
|
register('en', () => import('./_locales/en.json'))
|
||||||
register('pt-BR', () => import('./_locales/pt-BR.json'))
|
register('pt-BR', () => import('./_locales/pt-BR.json'))
|
||||||
register('es-ES', () => import('./_locales/es-ES.json'))
|
register('es-ES', () => import('./_locales/es-ES.json'))
|
||||||
|
register('ar', () => import('./_locales/ar.json'))
|
||||||
|
|
||||||
export async function preload(page, session) {
|
export async function preload(page, session) {
|
||||||
return waitLocale()
|
return waitLocale()
|
||||||
|
@ -14,10 +15,17 @@
|
||||||
import { _ } from 'svelte-i18n'
|
import { _ } from 'svelte-i18n'
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.rtl {
|
||||||
|
direction: rtl;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
<svelte:head>
|
<svelte:head>
|
||||||
<title>{$_('title.about')}</title>
|
<title>{$_('title.about')}</title>
|
||||||
</svelte:head>
|
</svelte:head>
|
||||||
|
|
||||||
<h1>{$_('about_this_site')}</h1>
|
<div class={$_('direction')}>
|
||||||
|
<h1>{$_('about_this_site')}</h1>
|
||||||
<p>{$_('about_content.0')}</p>
|
<p>{$_('about_content.0')}</p>
|
||||||
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user