BookMyStay BookMyStay Docs Buy Now
Step 7 · Languages

Languages & Localization

How to add new languages, configure Right-to-Left (RTL) mode, and update UI translation dictionaries in BookMyStay code.

Manual Code Translation GetX Localization RTL Supported

BookMyStay uses a clean, robust GetX Localization architecture (AppTranslations). UI strings (buttons, headings, labels, dialogs, empty states) are keyed directly by their English source text in Dart code dictionaries, while property content (hotel descriptions, room names, amenities) is stored per-language in Cloud Firestore.

Translations are Managed Manually in Code

In BookMyStay, UI strings are not uploaded as JSON files in the browser. Instead, you add or edit the translation dictionary directly in the Flutter code (strings_{locale}.dart). This ensures ultra-fast performance, zero network delay when switching languages, and offline availability on mobile devices.

Translation File Locations#

Both applications have their own translation dictionary folder:

customer/lib/app/translations/
├── app_translations.dart   # Central registry: supported locales, RTL set & keys map
├── strings_ar.dart         # Arabic (RTL)
├── strings_fr.dart         # French
├── strings_hi.dart         # Hindi
└── strings_sv.dart         # Swedish

admin_panel/lib/app/translations/
├── app_translations.dart   # Admin panel registry
├── strings_ar.dart         # Arabic
├── strings_fr.dart         # French
├── strings_hi.dart         # Hindi
└── strings_sv.dart         # Swedish

Step-by-Step: Adding a New Language#

Step 1 · Enable the Language in the Admin Panel

Open the Admin Panel and navigate to SettingsLanguages → click + Add Language.

Select your language from the preset dropdown (e.g., Spanish, German, Italian, Arabic) or enter custom values:

  • Language Name: e.g. Spanish
  • Language Code: 2-letter ISO code, e.g. es
  • Native Name: e.g. Español
  • Active & Default: Switch Active ON. Set Default ON if you want it as the primary system language.

This activates the language in Firestore so multi-language input fields (branch descriptions, room categories, amenities) immediately show the tab for this language.

Step 2 · Create the Code Translation Dictionary

In customer/lib/app/translations/, create a new file named after your language code (e.g. strings_es.dart for Spanish, strings_de.dart for German).

Copy an existing file (like strings_fr.dart) and translate only the right-side values:

customer/lib/app/translations/strings_es.dart
// UI strings for the 'es' locale, keyed by English source strings.
const Map<String, String> stringsEs = {
  "Search hotels and destinations": "Buscar hoteles y destinos",
  "Check-in": "Entrada",
  "Check-out": "Salida",
  "Book Now": "Reservar ahora",
  "My Bookings": "Mis reservas",
  "Booking Confirmed": "Reserva confirmada",
  "Total Branches": "Total de sucursales",
  "Amenities": "Servicios e instalaciones",
  "Pay at Hotel": "Pagar en el hotel",
  "Wallet Balance": "Saldo del monedero",
  "Filter": "Filtrar",
  "Apply": "Aplicar",
  "Cancel": "Cancelar"
};

Incremental & Safe Fallback

Never change the left-side key string. If a string is omitted or not yet translated, BookMyStay automatically falls back to the English key. Nothing will ever crash or show a blank label.

Step 3 · Register the Language in app_translations.dart

Open customer/lib/app/translations/app_translations.dart and add the new file in 3 places:

customer/lib/app/translations/app_translations.dart
import 'package:get/get.dart';

import 'strings_ar.dart';
import 'strings_fr.dart';
import 'strings_hi.dart';
import 'strings_sv.dart';
import 'strings_es.dart'; // 1. Import your new dictionary

class AppTranslations extends Translations {
  // 2. Add language code to supported list
  static const List<String> supported = ['en', 'ar', 'fr', 'hi', 'sv', 'es'];

  // 3. If Right-to-Left (e.g. Arabic 'ar', Hebrew 'he', Urdu 'ur'), add to rtl set:
  static const Set<String> rtl = {'ar'};

  @override
  Map<String, Map<String, String>> get keys => {
        'ar': stringsAr,
        'fr': stringsFr,
        'hi': stringsHi,
        'sv': stringsSv,
        'es': stringsEs, // 4. Map the language code to the dictionary
      };
}

Step 4 · Translate the Admin Panel (Optional)

If you want the web Admin Panel dashboard itself translated into the new language, repeat Steps 2 & 3 inside admin_panel/lib/app/translations/:

  • Create admin_panel/lib/app/translations/strings_es.dart.
  • Register 'es': stringsEs in admin_panel/lib/app/translations/app_translations.dart.

Step 5 · Test & Switch Languages

Re-run your application (or hot reload):

cd customer
flutter run

Open the Customer App or Website, navigate to Account → Language, and select your new language. The interface instantly updates to the translated text!

Right-to-Left (RTL) Layouts#

BookMyStay has built-in automated RTL mirroring for Arabic (ar), Hebrew (he), and Urdu (ur). When an RTL locale is active, the layout automatically flips:

  • Navigation drawers and back arrows mirror smoothly.
  • Search bars and text fields align to the right.
  • Price tags and room detail badges adjust reading direction automatically.

To enable RTL for any language, simply add its 2-letter code to the rtl set in app_translations.dart:

static const Set<String> rtl = {'ar', 'ur', 'he'};