1. Home
  2. Docs
  3. Mdelicious – Documents
  4. How to
  5. How to Build a Multi-Language App?

How to Build a Multi-Language App?

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 – Afrikaans
  • am – Amharic
  • ar – Arabic
  • as – Assamese
  • az – Azerbaijani
  • be – Belarusian
  • bg – Bulgarian
  • bn – Bengali Bangla
  • bs – Bosnian
  • ca – Catalan Valencian
  • cs – Czech
  • da – Danish
  • de – German (plus one country variation)
  • el – Modern Greek
  • en – English (plus 8 country variations)
  • es – Spanish Castilian (plus 20 country variations)
  • et – Estonian
  • eu – Basque
  • fa – Persian
  • fi – Finnish
  • fil – Filipino Pilipino
  • fr – French (plus one country variation)
  • gl – Galician
  • gsw – Swiss German Alemannic Alsatian
  • gu – Gujarati
  • he – Hebrew
  • hi – Hindi
  • hr – Croatian
  • hu – Hungarian
  • hy – Armenian
  • id – Indonesian
  • is – Icelandic
  • it – Italian
  • ja – Japanese
  • ka – Georgian
  • kk – Kazakh
  • km – Khmer Central Khmer
  • kn – Kannada
  • ko – Korean
  • ky – Kirghiz Kyrgyz
  • lo – Lao
  • lt – Lithuanian
  • lv – Latvian
  • mk – Macedonian
  • ml – Malayalam
  • mn – Mongolian
  • mr – Marathi
  • ms – Malay
  • my – Burmese
  • nb – Norwegian Bokmål
  • ne – Nepali
  • nl – Dutch Flemish
  • no – Norwegian
  • or – Oriya
  • pa – Panjabi Punjabi
  • pl – Polish
  • ps – Pushto Pashto
  • pt – Portuguese (plus one country variation)
  • ro – Romanian Moldavian Moldovan
  • ru – Russian
  • si – Sinhala Sinhalese
  • sk – Slovak
  • sl – Slovenian
  • sq – Albanian
  • sr – Serbian (plus 2 scripts)
  • sv – Swedish
  • sw – Swahili
  • ta – Tamil
  • te – Telugu
  • th – Thai
  • tl – Tagalog
  • tr – Turkish
  • uk – Ukrainian
  • ur – Urdu
  • uz – Uzbek
  • vi – Vietnamese
  • zh – 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

Was this article helpful to you? Yes No

How can we help?