Docs
String translations 🌐

String translations 🌐

atomsbox's templates can support multiple languages.

atomsbox's templates are localized following the guidelines from the official Flutter documentation on internationalization. The goal is to allow you to adapt the template for your local market easily.

Adding More Strings to the ARB Files

As you modify the template, you might need more localized strings, and, it's quite easy to add more.

  • Open the app_en.arb file
# lib/l10n/app_en.arb
{
  "project_name": "Doctor Booking App",
  "app_name": "DocFinder",
  "chats": "Chats",
  "settings": "Settings",
  "error": "Something went wrong",
  ...
}
  • Add a new key-value pair in the dictionary. Important: The last key-value pair in the dictionary should not be followed by a comma (,).
# lib/l10n/app_en.arb
{
  ...
  "new_string": "New string",
  ...
}

After you hot-restart the application, you will be able to use the new localized string.

# In any screen of your app 

class HomeView extends StatelessWidget {
  const HomeView({super.key});

  @override
  Widget build(BuildContext context) {
    final localizations = AppLocalizations.of(context);

    return Scaffold(
      appBar: AppBar(
        title: Text(localizations.new_string),
      )
    );
  } 
}

Adding new ARB Files to Support More Languages

To support other languages, you will have to translate the string from the app_en.arb file.

  • Add a new ARB file in the lib/l10n/arb directory.
β”œβ”€β”€ lib
β”‚   β”œβ”€β”€ l10n
β”‚   β”‚   β”œβ”€β”€ app_en.arb
β”‚   β”‚   β”œβ”€β”€ app_it.arb
β”‚   β”‚   β”œβ”€β”€ ...
  • Copy all the localized strings form the original ARB file.

app_en.arb

{
  "project_name": "Doctor Booking App",
  "app_name": "DocFinder",
  "chats": "Chats",
  "settings": "Settings",
  "error": "Something went wrong",
  ...
}
  • Translate all the values while keeping the same keys. app_it.arb
{
  "project_name": "Doctor Booking App",
  "app_name": "DocFinder",
  "chats": "Conversazioni",
  "settings": "Impostazioni",
  "error": "Qualcosa Γ¨ andato storto!",
  ...
}