Skip to content

Localization

Kittox default language is English. Applications can be localized to any language using the GNU gettext system via dxgettext for Delphi.

Localization covers two layers:

  1. Framework interface — buttons (Save, Cancel, Edit, Confirm, Close, etc.), error messages, dialog text
  2. Application metadata — field labels, allowed values, view titles, hints defined in YAML

File Structure

Home/
  Locale/
    it/
      LC_MESSAGES/
        Kitto.po      # Translatable strings (source, editable)
        Kitto.mo       # Compiled binary (used at runtime)
        Kitto.ini      # dxgettext configuration
    de/
      LC_MESSAGES/
        Kitto.po
        Kitto.mo
    fr/
      ...

The framework locale folder is in KittoX/Home/Locale/. The application locale folder is in {App}/Home/Locale/. At runtime, KittoX searches the application folder first, then the framework folder (same fallback pattern as resources).

.po file (source)

The .po file contains translatable strings in standard GNU gettext format:

po
#: Kitto.Html.Form.pas
msgid "Save All"
msgstr "Salva tutto"

#: Kitto.Web.Application.pas
msgid "Session lost or expired, please restart!"
msgstr "Sessione persa o scaduta, riavviare!"

Edit .po files with Poedit (free), which compiles the .mo automatically on save.

.mo file (compiled)

The .mo file is the binary format read by dxgettext at runtime. It is generated from the .po file by Poedit or the msgfmt command-line tool. Always regenerate the .mo after editing the .po.

Framework Strings

The framework .po file (KittoX/Home/Locale/it/LC_MESSAGES/Kitto.po) includes translations for:

CategoryExamples
Form buttonsSave, Confirm, Save All, Cancel, Close, Edit, Delete, Add, Save & Clone
Form titlesAdd %s, Edit %s, View %s, Duplicate %s
List/GridFilters, Apply, Refresh, Search, Select, No records found, Showing %d-%d of %d
Confirmation dialogsSelected %s will be deleted. Are you sure?, Yes, No
LoginUser Name, Password, Language, Login, Logging in..., Invalid login., Logout
PasswordChange Password, Old Password, New Password, Reset Password
Error handlingError, Server is not responding, Retry, Reset, Server error, Resource not found
SessionSession lost or expired, please restart!, Data saved, Data deleted
File operationsUpload, Download, Clear, Preview

Italian translation is included out of the box. To add a new language, copy the it/ folder, rename it (e.g. de/, fr/, es/), and translate the .po file.

Client-Side Strings

Some strings are used in JavaScript (error dialogs, toast notifications). These are injected from the server into the _Page.html template via the window.KX_STRINGS object:

javascript
window.KX_STRINGS = {
  appTitle: '...',
  errorTitle: '...',       // _('Error')
  serverNotResponding: '...', // _('Server is not responding')
  retry: '...',            // _('Retry')
  reset: '...',            // _('Reset')
  dataSaved: '...',        // _('Data saved')
  dataDeleted: '...',      // _('Data deleted')
  serverError: '...',      // _('Server error')
  serverNotFound: '...',   // _('Resource not found')
  serverInternalError: '...' // _('Internal server error')
};

These values come from the Delphi _() function, so they are automatically translated when a .po/.mo file is available for the user's language.

Application Metadata Localization

In YAML metadata files, wrap translatable strings with _():

Field labels and hints

yaml
Fields:
  Doll_Name: String(40) not null
    DisplayLabel: _(Name)
  Date_Bought: Date
    DisplayLabel: _(Birth Date)
  Picture: Blob
    DisplayLabel: _(Photo)
    Hint: _(Select a picture)

Allowed values

yaml
Fields:
  Dress_Size: String(4)
    AllowedValues:
      XS: _(Extra Small)
      S: _(Small)
      M: _(Medium)
      L: _(Large)
      XL: _(Extra Large)

View titles and button labels

yaml
Views:
  MyView:
    DisplayLabel: _(Customer List)
    Controller: List

Delphi Code

In custom controllers and rules, use _() for user-facing strings:

pascal
uses
  EF.Localization;

procedure TMyRule.BeforeAdd(const ARecord: TKRecord);
begin
  if SomethingWrong then
    RaiseError(_('Cannot invite the same girl twice.'));
end;

Multi-Language Applications

To let users choose their language at login, add to Config.yaml:

yaml
LanguageId: en
LanguagePerSession: True
  • LanguageId sets the default language for the login page
  • LanguagePerSession: True shows a language selector on the login dialog

The language selector lists all locale subfolders found in Home/Locale/.

Adding a New Language

  1. Copy an existing locale folder (e.g. Home/Locale/it/) to a new folder (e.g. Home/Locale/de/)
  2. Open Kitto.po with Poedit
  3. Translate all msgstr entries
  4. Save — Poedit generates the .mo file automatically
  5. For application-specific strings, create the same structure in {App}/Home/Locale/de/LC_MESSAGES/

See also

Released under Apache License, Version 2.0.