SaFi Bank Space : App Localization

Asset Language

We can add asset language as json file, for our app there are two json files en.json and fil.json, for example :

en.dart

final Map<String, String> translations = {
  "login.journey.welcome.text.welcome" : "Welcome to Safi",
  "login.journey.welcome.button.i18n_with_params" : " Hi %s, you are an %s !"
}

fil.dart

final Map<String, String> translations = {
  "login.journey.welcome.text.welcome" : "Maligayang pagdating sa Safi",
  "login.journey.welcome.button.i18n_with_params" : "PH: Hi %s, you are an %s !"
}

Naming Convention

For naming convention :

Feature_name.sub_presentation_folder.screen_name.widget_name.title_of_text
example :

"login.journey.welcome.text.welcome"

How To Use

Add a class for string constant, example :

class WelcomeConstants {
  static const String welcomeToSafi = 'login.journey.welcome.text.welcome';
  static const String exampleWithParams = 'login.journey.welcome.button.i18n_with_params';
}

And implement to the code :

Your_constant.i18n(context) or with params Your_constant.i18n(context, params:["your param"])

example :

Text(
  WelcomeConstants.welcomeToSafi.i18n(context),
  style: TextStyles.h2(context),
),

example with params :

Text(
  exampleWithParams.i18n(
    context,
    params: ["JoShua", "Admin"],
  ),
  style: TextStyles.h2(context),
),

Implement formal and non-formal (Tone of Voice)

Onboarding squad already implement formal and non formal Tone of Voice, you need to add the key of translations on 4 files, there are :

  • en.dart

  • fil.dart

  • en_friendly.dart

  • fil_friendly.dart

actually the implimentation is same as en.dart and fil.dart, you just need to add the key and translations to en_friendly.dart and fil_friendly.dart . they will override key on en.dart and fil.dart if the user use friendly tone of voice.

en_friendly.dart

final Map<String, String> translations = {
  "login.journey.welcome.text.welcome" : "Welcome to Safi (Friendly)",
  "login.journey.welcome.button.i18n_with_params" : " Hi %s, you are an %s !(Friendly)"
}

fil_friendly.dart

final Map<String, String> translations = {
  "login.journey.welcome.text.welcome" : "Maligayang pagdating sa Safi (Friendly)",
  "login.journey.welcome.button.i18n_with_params" : "PH: Hi %s, you are an %s !(Friendly)"
}