How does translation work?
- The yellow areas are defined in the language file in app (en.json, ar.json …)
- The red area is defined in the App builder plugin
- The green area is content (post, product, category) in the plugin translated like WPML, Polylang.
Set default language
To set a defaultLanguage and defaultLocale for your app open languages.dart file located in:
mdelicious_food/lib/constants/languages.dart
Then change the language code to your own language as shown below screenshot and you are all good to go:
NOTE!
Some languages with multiple variants require more than just a language code to properly differentiate. So you must setting defaultLocale.
Add language to App
By default, English and Arabic language files are included in the app. To add your language to the app follow the below steps:
In this step, we will show you how to add your own language to our Mdelicious flutter app.
Go to your Mdelicious folder and navigate to:
/assets/lang
You will find en.json and ar.json now, copy en.json file then rename it to your language locale code, for example for Italian it will be: it.json for French it will be: fr.json. Now only translate your duplicated and renamed file to your own language.
Next step you need to navigate to languages.dart file located in:
/lib/constants/languages.dart
Open it and add your locale code as shown in the below screenshot
NOTE!
If your website is multi-lingual and you want to make your app as Multi-Lingual, you will need to have WPML installed on your website so multi-lingual functionality can work.
Make app multi-language without translation plugin.
The app automatically detects your setting languages on the website if the translate plugin is installed. But for some apps, you only need to translate the app without content.
You can manually define the languages configs in the file wp-config.php like this:
define( 'APP_BUILDER_LANGUAGES', serialize( array(
'en' => array(
'code' => 'en',
'language_code' => 'en',
'native_name' => 'English',
),
'ar' => array(
'code' => 'ar',
'language_code' => 'ar',
'native_name' => 'Arabic',
)
) ) );
The following locales are supported:
Flutters official supported 78 languages.
af
– Afrikaansam
– Amharicar
– Arabicas
– Assameseaz
– Azerbaijanibe
– Belarusianbg
– Bulgarianbn
– Bengali Banglabs
– Bosnianca
– Catalan Valenciancs
– Czechda
– Danishde
– German (plus one country variation)el
– Modern Greeken
– English (plus 8 country variations)es
– Spanish Castilian (plus 20 country variations)et
– Estonianeu
– Basquefa
– Persianfi
– Finnishfil
– Filipino Pilipinofr
– French (plus one country variation)gl
– Galiciangsw
– Swiss German Alemannic Alsatiangu
– Gujaratihe
– Hebrewhi
– Hindihr
– Croatianhu
– Hungarianhy
– Armenianid
– Indonesianis
– Icelandicit
– Italianja
– Japaneseka
– Georgiankk
– Kazakhkm
– Khmer Central Khmerkn
– Kannadako
– Koreanky
– Kirghiz Kyrgyzlo
– Laolt
– Lithuanianlv
– Latvianmk
– Macedonianml
– Malayalammn
– Mongolianmr
– Marathims
– Malaymy
– Burmesenb
– Norwegian Bokmålne
– Nepalinl
– Dutch Flemishno
– Norwegianor
– Oriyapa
– Panjabi Punjabipl
– Polishps
– Pushto Pashtopt
– Portuguese (plus one country variation)ro
– Romanian Moldavian Moldovanru
– Russiansi
– Sinhala Sinhalesesk
– Slovaksl
– Sloveniansq
– Albaniansr
– Serbian (plus 2 scripts)sv
– Swedishsw
– Swahilita
– Tamilte
– Teluguth
– Thaitl
– Tagalogtr
– Turkishuk
– Ukrainianur
– Urduuz
– Uzbekvi
– Vietnamesezh
– Chinese (plus 2 country variations and 2 scripts)zu
– Zulu
Config WPML/Polylang
Setting name plugin multi language in file mdelicious_food/lib/constants/languages.dart