LOCALIZING
FLUTTER
APPS
Shams Ali
shamsali0404@[Link]
Step 1
Add this in '[Link]' file under dependencies
Add generate: true under the flutter tag
Shams Ali
shamsali0404@[Link]
Step 2
Create 'l10n' folder under your 'lib' directory.
Inside this folder, create a '[Link]' file which will
contain all the supported locales
This is how the '[Link]' file would look like
Shams Ali
shamsali0404@[Link]
Step 3
Assign all the locales defined in '[Link]' file,
to 'supportedLocales' property in MaterialApp widget.
Create '[Link]' file in 'root' directory and add this
configuration
Shams Ali
shamsali0404@[Link]
Step 4
Create 2 more files 'app_en.arb' and 'app_ar.arb' under 'l10n'
folder representing translations for English and Arabic
respectively (where .arb is application resource bundle file)
Define key and value for each text that will be used in the app
Shams Ali
shamsali0404@[Link]
Step 5
NOTE: Before proceeding further let's run the app first so that it
can generate translation files internally
(stop and re-run [Link] if it's already running)
Now import these dependencies in [Link] file
After doing so, add this snippet inside your MaterialApp widget
Shams Ali
shamsali0404@[Link]
Usage
Specify your locale in MaterialApp widget. We can always switch
the translations by changing Local('language_code')
Now, You can access all the defined translated texts using their
keys by this way. It will pickup the right translation automatically
based on selected locale
Shams Ali
shamsali0404@[Link]
THANK YOU!
Save and Share!
Shams Ali
shamsali0404@[Link]