Localizations
Information
Localization files location
src/locales/
and are used to define translation strings. This directory will contain a JSON file for each language supported by the theme. For applications with a large number of translatable strings, this strategy is recommended.Information
Note
...
└── src
├── locales
├── ar.json
├── en.json
.....
├── your-language-code.json
...
Configuration
"Key":"Value"
, that can be found in a JSON string file. A colon sign :
separates the key and value strings, which are then enclosed by a main key value that groups the key-value pairs according to their intended purpose. Below is a very basic JSON structure with a main key value and a list of key-value pairs for translation.{
"common": {
"modal": {
"remember_my_choice": "لا تذكرني مرة اخرى",
"note": "ملاحظة",
"country_code":"كود الدولة",
"copy_code": "نسخ الكود"
}
}
}
locales/ar.json
can be as follows:{
"blocks": {
"header": {
"cart": "السلة",
"login_by_sms": "تسجل الدخول برسالة نصية",
"login_by_email": "تسجل الدخول بالبريد الإلكتروني"
},
"home": {
"browse_brands": "تصفح من خلال العلامات التجارية"
}
}
}
Best practices for Localizations
1.
2.
Translation retrieval
<!-- simple key -->
<span>{{ trans('common.remember_my_choice') }}</span>
<!-- key with variable -->
<span>{{ trans('blocks.header.cart', ['word' => 'Products']) }}</span>
<!-- key with enforced locale/language -->
<!-- this will always print the result of key in English even if the store has different default language -->
<span>{{ trans('common.titles.orders', [], en) }}</span>
A thing to know!
الإضافة إلى السلة
to تبرع الآن
. Learn more about overriding process here.Supported Languages
Code | Language |
---|---|
ar | العربية |
en | English |
sq | shqip |
hy | հայերէն |
bg | български |
zh | 汉语 |
hr | hrvatski |
cs | čeština |
da | dansk |
nl | dutch |
et | eesti keel |
fi | suomen kieli |
fr | français |
de | Deutsch |
el | Ελληνικά |
he | עִבְרִית |
hi | हिन्दी |
hu | magyar |
ind | bahasa Indonesia |
ga | Gaeilge |
it | italiano |
ja | 日本語 |
ko | 한국어 |
lv | latviešu |
mt | Maltese |
fa | فارسی |
pl | Polish |
pt | português |
ro | română |
ru | русский |
sl | slovenščina |
es | español |
sv | svenska |
tl | Tagalog (Filipino) |
tr | Türkçe |
uk | украї́нська |
ur | اُردُو |
Educational Clip
Modified at 4 months ago