Flutter Internationalization

Flutter Internationalization

When you create a mobile app and it hits the international market, you have to internationalize the app which is an important part of app development. Let discuss how to implement internationalization in Flutter.

Add following dependency by below commands

flutter pub add flutter_localizations --sdk=flutter
flutter pub add intl:any        

These command will add the following dependecy in Pubsec.yaml

dependencies:
 flutter:
flutter_localizations:
    sdk: flutter
  intl: any
         

Now add a new yaml file in the root directory with the name i18n.yaml and add the following codes.

arb-dir: lib/l10n
template-arb-file: app_en.arb
output-localization-file: app_localizations.dart        

create a folder in the lib directory with the name I10n and then create a file named app_en.arb for english and app_es.arb for spanish and add following codes.

for english

{
  "helloWorld": "Hello World!",
  "title": "Flutter demo",
  "you_have_click_button_this_many_time": "You have clicked button this many times",
  "flutter_demo_page": "Flutter Demo Home Page",
  "increment": "Increment"

}
        

for spanish

{
    "helloWorld": "?Hola Mundo!",
    "title": "Demostración Flutter",
    "you_have_click_button_this_many_time": "Has hecho clic en este botón muchas veces.",
    "flutter_demo_page": "Página de demostración flutter",
    "increment": "INCREMENTO"

}        

Now run command

flutter gen-l10n        

to generate the translation


now apply the translation

to Widget

var localization =AppLocalizations.of(context);
Text(localization!.title);        

that's done .

like that you can enjoy Internationalization in your app. You can checkout the example in github with given below repository.

https://github.com/iamrajendraverma/cloud

bye bye enjoy coding


要查看或添加评论,请登录

Rajendra Verma的更多文章

  • My First AI Model

    My First AI Model

    If you will check the below table, then you will get to know that Y is dependent on X and the relationship is. y = 2x -…

  • Evolution of Neural Network

    Evolution of Neural Network

    This is a very intersecting topic, just like an Netflix webseries. Now a days everyone is talking about AI, but no one…

  • What is Deep Learning?

    What is Deep Learning?

    A subset of machine learning: Deep learning is a branch of machine learning that focuses on using artificial neural…

  • Very Good CLI vs Flutter CLI: A Clear Distinction

    Very Good CLI vs Flutter CLI: A Clear Distinction

    We all know about Flutter cli, that it is known to develop the project and that it works to update and upgrade the…

  • Mixin in dart

    Mixin in dart

    Flutter is becoming the most popular language now for mobile development. When developers write code, they encounter…

  • Types of provider in Flutter

    Types of provider in Flutter

    I was working on one of my Flutter projects, and suddenly I thought that it is a good idea to explain the difference…

  • Flutter

    Flutter

    A couple of days ago, I was thinking of learning to flutter because of market requirements. But I find it too easy and…

  • My Experiment with the Matter Protocol

    My Experiment with the Matter Protocol

    Exploring the Future of IoT: An In-Depth Look at the Matter Protocol As a software engineer specializing in IoT…

  • How to filter array of a positive integer and negative integer in kotlin

    How to filter array of a positive integer and negative integer in kotlin

    Interviews are asking a general question nowadays from Kotlin developers so that I like to give its answer fun main(){…

  • Print numbers with using recursion and without using recursion and loop in java.

    Print numbers with using recursion and without using recursion and loop in java.

    I was taking the interview and the thought comes, let's put a question to the interviewee that you have to print…

社区洞察

其他会员也浏览了