# Custom Translation

You can translate the app to your own language if its not listed as one of the supported languages.

Here is how you can translate it yourself.

* Go to **/lib/constants/app\_languages.dart**
* You will see 3 arrays in the file.&#x20;
  * Codes -  this is where the language code for each language is saved.&#x20;
  * names - the name of the language to be shown to user during language change/selection
  * flags - the code for the language countries

![](/files/cLgjoJhbHYd46jd4eODa)

* You can add yours if you want. For example if you want to translate app to **Yoruba(**&#x41; local language in Nigeri&#x61;**).** Below is the sample of how the code should look like:

![](/files/MzXhTtrrCFVx2KEcW9zd)

Now **Yoruba** will be listed as one of the app languages.

## Translating App Strings

### String with .i18n (In few places)

After setting your custom language option above, all you are left with is to translate all the used strings used in the app to your custom language.

All translatable strings/values used in the app is grouped inside a **translation** folder. For example if you want to translate the values on the splash page. Navigate to **lib/translations/splash.i18n.dart.**&#x20;

Here is a the content of **splash.i18n.dart:**

```dart
import 'package:i18n_extension/i18n_extension.dart';

extension Localization on String {
  //en,fr,es,de
  static var _t = Translations("en") +
      {
        "en": "Loading Please wait...",
        "fr": "",
        "es": "",
        "de": "",
      };

  String get i18n => localize(this, _t);
  String fill(List<Object> params) => localizeFill(this, params);
}

```

Now you need to set your translated string/value for each object.&#x20;

Now let us translation the value  **"**&#x4C;oading Please wait..." to **Yoruba.** This is how the file would now look like:

```dart
import 'package:i18n_extension/i18n_extension.dart';

extension Localization on String {
  //en,fr,es,de
  static var _t = Translations("en") +
      {
        "en": "Loading Please wait...",
        "fr": "",
        "es": "",
        "de": "",
        "yo": "Nbọ Jọwọ duro ...",
      };

  String get i18n => localize(this, _t);
  String fill(List<Object> params) => localizeFill(this, params);
}

```

That's it, you now have a translated version of that value. You can follow the guide above to translate the rest values in all the translation files.&#x20;

**NOTE:** All translation file as an extension of **.i18n.dart**

### **String with .tr()**

Starting from 1.5.0, our apps now uses a different approach for string translation. Translatable strings/words now ends with the **.tr()** function. All string have been save in a json file in asset folder according to the language code to make it easy to translate work with need strings/words.

For example: if you need to fix a wrong translation in your language, using **Spanish** for this example. You need to open the **es.json** file in your **assets/lang** folder. You will see all the english version of the string and the corresponding **Spanish** version, you can then edit the spanish version as you like/wish.

&#x20;E.g **en.json** is for english, **fr.json** is for french, **ar.json** is for arabic etc

## **Default Language**

You can make the newly added language the default language of the app.

Navigate to **lib/services/auth.service.dart.** Change the code at line 39. Current code from line 39

```dart
static String getLocale() { 
    return LocalStorageService.prefs.getString(AppStrings.appLocale) ?? "en"; 
}
```

To make **Yoruba** our default language, change the **"en"** to **"yo".**&#x20;

## REMOVE LANGUAGE

If you need to remove unwanted languages, you can simply comment out the languages you don't want from the **/lib/constants/app\_languages.dart** file


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://edentech.gitbook.io/instahaul/flutter-app/custom-translation.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
