0% found this document useful (0 votes)
67 views8 pages

Flutter App Localization Guide

The document outlines 5 steps to localize a Flutter app: 1) Add localization dependencies to pubspec.yaml, 2) Create an l10n folder and file to define supported locales, 3) Assign locales to MaterialApp, 4) Create .arb files for translations, and 5) Import dependencies and specify locale in MaterialApp. It also provides examples of how to specify and access translations based on locale.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
67 views8 pages

Flutter App Localization Guide

The document outlines 5 steps to localize a Flutter app: 1) Add localization dependencies to pubspec.yaml, 2) Create an l10n folder and file to define supported locales, 3) Assign locales to MaterialApp, 4) Create .arb files for translations, and 5) Import dependencies and specify locale in MaterialApp. It also provides examples of how to specify and access translations based on locale.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

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]

You might also like