Skip to main content

Language Configs

In this section you can learn how to add or remove more languages in the application using android studio.

Add New Language#

To add new language in the application you will need to create some files. This guide will create new files using android studio.

  1. Open android studio on your machine.

  2. Open Plugins window from Preferences on macOS and Settings on Windows.

  3. Select Marketplace option from the top tabbar.

  4. In the search field enter Flutter Intl.

    Flutter Intl Installation

  5. Click on Install and Apply. You will need to restart android studio for the plugin to be activated.

  6. From the Tools menu option select Flutter Intl and click on Add locale.

    info

    Checkout this link to see the names and code of the locales supported: Official Support Locales

    Flutter Intl Installation

  7. Add the language code in the field and click Ok. For example is we were to add Arabic then we will write ar in the field.

  8. This will create a new intl_xx.arb file in the woostore_pro / lib / l10n directory. This file will be empty by default.

  9. Open the intl_en.arb file from woostore_pro / lib / l10n directory in android studio. Copy all the contents of the file and paste it into the newly created intl_xx.arb file.

  10. Replace the @@locale key value with the language code of the new language you created.

    intl_en.arb
    {
    "@@locale": "en",
    ...
    }
    intl_xx.arb
    {
    "@@locale": "xx",
    ...
    }

    Replace the xx with the actual language code.

  11. Finally Save the file by pressing command + s on Mac and control + s on Windows.

You will also need to enter some more modifications in the application to show an option to change the locale to the newly added language. Follow the steps below to add the same.

  1. Open languages.dart file in android studio. This file is located in woostore_pro / lib / constants / languages.dart

  2. Edit the kSupportedLanguages variable with the new language entry.

  3. The following is the structure of each language entry in the application. You need to follow the same pattern while adding the new entry.

    {
    'languageCode': 'en',
    'countryCode': 'US',
    'title': 'English',
    'asset': 'united-states.svg'
    },
  4. The asset in the above code snippet is an SVG format file which represents the flag of the corresponding country. You need to add the asset in woostore_pro / lib / assets / svg / flags directory. Make sure the same is same as you enter in the asset field above.

Remove Language#

If you have installed Flutter Intl plugin#

  1. From the Tools menu option select Flutter Intl and click on Remove locale.

    Flutter Intl Installation

  2. Select the language code from the dropdown and click Ok. For example is you were to remove Arabic then you will select ar in the field. This will remove the language from the application.

If you have not installed Flutter Intl plugin#

  1. Open android studio on your machine.

  2. Open Plugins window from Preferences on macOS and Settings on Windows.

  3. Select Marketplace option from the top tabbar.

  4. In the search field enter Flutter Intl.

    Flutter Intl Installation

  5. Click on Install and Apply. You will need to restart android studio for the plugin to be activated.

  6. From the Tools menu option select Flutter Intl and click on Remove locale.

    Flutter Intl Installation

  7. Select the language code from the dropdown and click Ok. For example is you were to remove Arabic then you will select ar in the field. This will remove the language from the application.