Skip to content

Internationalization

Internationalization (i18n) is the process of adapting an application to support multiple languages and regions. In this guide, we will show you how to add texts and translations to your flutter app.

Getting started

Add the text you want to translate to the lib/l10n/arb/app_en.arb file.

json
{
  "test": "Test",
}

Next, add the translations for the text in the lib/l10n/arb/app_<language_code>.arb file. Replace <language_code> with the language code of the language you want to add.

json
{
  "test": "পরীক্ষা",
}

Usage

To use the translated text in your app, you can use the AppLocalizations class. The AppLocalizations class provides a way to access the translations in your app.

dart
import 'package:flutter/material.dart';
import 'package:techshoi_app/l10n/l10n.dart';

class TestWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Text(context.l10n.test);
  }
}