InstaHaul
  • Introduction
  • Usage Flows (FlowCharts)
  • Firebase
    • Firebase
    • Firebase firestore database
    • Firebase Security
    • Firebase Storage
    • Firestore indexes
    • Chat & Live tracking
  • Backend
    • Prerequisite
    • VPS/Shared Hosting
    • Installation
    • Composer & Node Packages
    • Database Configuration
    • GUI Installer
    • Timezone
    • Firebase
    • Web Notification
    • Firebase Forgot password
    • Change Backend Color
    • Reskin Mobile App
    • Terminal
      • Commands
    • Screenshots
    • Order schedule
    • CRON job
    • Clear Data (Users/Orders etc)
    • Email Server Settings
    • SMS Gateway
    • Payment Gateways
    • Webhooks - Payment gateway
    • Language / Translation
    • HOW TO UPDATE
    • In-App Live chat/support
    • Geocoding and Place search
    • Features
      • Firebase/Notification Delay
      • Fleet Management
      • Loyalty points
      • Home Screen Design
      • Featured Vendors
      • Trip recalculation/Outstanding payments
      • Switch between Taxi/Regular Driver
      • Data Translation - Backend
  • Flutter App
    • Getting Started
    • Steps
    • Directory Structure
    • Change App Name & ID
    • Change App icon & splash
    • App Color / Theme
    • Connect To Backend
    • Firebase
    • Firebase Auth - Phone
    • Firebase Phone OTP - Android
    • Firebase Phone OTP - iOS
    • Firebase Notification iOS
    • Share link - Firebase dynamic link
    • Social Media Login
      • Google login
      • Facebook Login
      • Sign-In with Apple
    • Google Map
    • Change App Language
    • Notification Sound
    • Custom Translation
    • Change App Font
    • Running on VS Code
    • Running on Android Studio
    • Generate Android Release App
    • Upload to Apple App Store
    • Screenshots
  • Demo Accounts
  • FAQs
    • Backend Image not working
    • Backend Backup not working
    • Upgrade without losing data
    • Backend Rollback
    • Blank Home screen
    • Custom Token
    • Product price zero(0) in details
    • Auto-cancel Not working
    • Pharmacy vendor
    • Vendor default rating
    • App logins
    • Error ==> type 'String' is not a subtype of type 'int'
    • NDK version error
    • Push Notification
    • Delivery Zone Map error
    • HOW TO UPDATE ADMINEND
    • Driver app rejected by Google
    • Cron job error
    • Auth pages Not working - App
  • HOW-TO
    • Onboarding Settings
    • Earning
      • Drivers
    • Enforce CASH Payment For Delivery Fee Only
    • System Contact Email
    • Driver Matching Flow
  • Extensions
    • Driver tracking extensions
    • Paymongo Gateway
    • Mercadopago Gateway
    • Nagad [Bangladeshi]
    • Instamojo - Payment
    • Paytrail
    • Paymaya Gateway
    • Emailer
    • External Notifier
      • Slack Setup
      • Telegram Setup
  • Upgrades
    • How to update
    • Important: Backend VPS/Shared hosting
    • 1.0.1
    • 1.1.00
    • Change logs
Powered by GitBook
On this page
  • Translating App Strings
  • String with .i18n (In few places)
  • String with .tr()
  • Default Language
  • REMOVE LANGUAGE
  1. Flutter App

Custom Translation

PreviousNotification SoundNextChange App Font

Last updated 1 year ago

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.

    • Codes - this is where the language code for each language is saved.

    • names - the name of the language to be shown to user during language change/selection

    • flags - the code for the language countries

  • You can add yours if you want. For example if you want to translate app to Yoruba(A local language in Nigeria). Below is the sample of how the code should look like:

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.

Here is a the content of splash.i18n.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.

Now let us translation the value "Loading Please wait..." to Yoruba. This is how the file would now look like:

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.

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.

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

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

To make Yoruba our default language, change the "en" to "yo".

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