Introducing a new way to review your PRs.

Read the announcement

transmission-remote-gui / transgui

🧲 A feature rich cross platform Transmission BitTorrent client. Faster and has more functionality than the built-in web GUI.

View on GitHub

19 documents · Updated Sep 25, 2026

docs / localization

Localization and language resources

Localization gives Transmission Remote GUI one language model for its Lazarus desktop interface. Pascal resource strings, form text, and selected text from the remote Transmission service can use the same language resource files. The system chooses a language at start-up, applies it to the interface, and keeps the source text as a safe fallback.

Translation resources

Translation resources are UTF-8 text files that map a source string to its translated text. Each file also names the language that it supplies, so the application can show a human-readable choice in the settings window instead of relying only on a file suffix. The lang/transgui.template file is the source list for resource maintenance, while files such as lang/transgui.ru provide a language-specific result. References: lang/transgui.template#L1-L10, lang/transgui.ru#L1-L10, restranslator.pas#L128-L130

Resource entry format

Each entry uses a source=translation pair. Quoted values allow a source or translation to contain the separator or a line break marker. The format keeps placeholders such as %s and %d in the translated value because the calling code still supplies those values. An ampersand marks a keyboard access key; when a translation does not keep that key, the translator can place it on a matching letter.

The first entry uses the reserved TranslationLanguage name. Its value is the display name used in the language list. A .template file is a working source and is not offered as a selectable language.

References: restranslator.pas• L144-227 restranslator.pas• L633-698 lang/transgui.template• L1-24

Resource coverage

The resource set covers strings declared as Pascal resourcestring values and text stored in Lazarus form resources. It can also gain entries at run time when the application translates text that comes from the remote service. A missing entry returns the original text, which lets a partial translation remain usable.

References: main.pas• L48-155 restranslator.pas• L802-871 restranslator.pas• L899-926

Language selection

Language selection combines an optional saved file choice with the operating system locale. The application reads the saved choice from its interface settings; when no valid choice exists, it searches for a resource that matches the current locale. A user change takes effect after restart, which lets the next start-up load one language before forms are created. See application lifecycle for the wider start-up sequence and desktop interface and preferences for the settings flow.

The normal language directory is next to the application. On Unix systems the search can also use the shared application directories under /usr/share/<application>/lang/ and /usr/local/share/<application>/lang/. The search uses the application name as the file prefix and accepts a language resource only when its file exists and its suffix is not one of the known non-language suffixes.

When the operating system supplies a regional language, the search tries these forms in order:

  1. The full language and region, such as uk_ua.
  2. The base language, such as uk.
  3. The region name, such as ua.

If none is present, the interface stays in English.

This diagram shows how the saved preference and system locale lead to the resource loaded by the interface.

flowchart TD
    A[Start application] --> B{Translation file saved?}
    B -->|Valid file| C[Load saved resource]
    B -->|No or invalid file| D[Read system language and region]
    D --> E[Try full locale]
    E -->|Missing| F[Try base language]
    F -->|Missing| G[Try region]
    G -->|Missing| H[Use English source text]
    E -->|Found| C
    F -->|Found| C
    G -->|Found| C
    C --> I[Apply translations to Lazarus resources]
    H --> I

References: restranslator.pas• L271-301 restranslator.pas• L405-464 main.pas• L1257-1271

Preference selection

The options window builds its language list from the valid resources in the language directory. It always includes English as the source-language choice. Saving a translated choice stores its file name in the interface settings; saving English stores -. The application reports a restart requirement because the language is loaded during start-up rather than switched in place.

References: options.pas• L221-241 options.pas• L257-284 main.pas• L1257-1271

Translation utilities

The translation utilities provide one path for loading, looking up, creating, and updating resources. They operate on the active translator and can use a callback to accept or reject a particular resource when a special screen needs different treatment.

Runtime lookup

TranslateString is the direct lookup utility for text that is not already supplied through a Lazarus resource property. It returns the source text when no translator is active or when no matching entry exists. The external-text flag marks text that came from outside the compiled interface, which allows that text to be included when resources are maintained.

Lazarus resource strings and form properties use the active translator automatically. The translator keeps form names unchanged and can skip selected properties through its callback. This keeps localization focused on user-visible text rather than object identity.

References: restranslator.pas• L303-324 restranslator.pas• L516-523 restranslator.pas• L899-926

Resource maintenance

Resource maintenance starts from the strings seen by the active translator. A make operation creates a new language file with the current source names. An update operation supplements existing language files and the template with new names while retaining existing translations. These operations run at application shutdown when the corresponding command-line mode is used, after the application has created all forms so their text is visible to the resource scan.

References: restranslator.pas• L331-400 main.pas• L1926-1952

Lazarus interface delivery

The Lazarus interface receives translations through the resource-string system rather than through separate copies of each form. The application loads the active file before normal form use, then the translator supplies translated values as Lazarus reads resource strings and form properties. Pascal units declare the source strings, while Lazarus form resources provide many control captions and labels.

Interface resource flow

This diagram shows how source text from compiled resources and remote data reaches a visible control or message.

flowchart LR
    A[Pascal resource strings] --> C[Active translator]
    B[Lazarus form resources] --> C
    D[Remote service text] --> E[TranslateString]
    E --> C
    C --> F[Localized captions and messages]

The application registers the active translator with Lazarus after it loads a file. This makes localization a shared service for the main window and its child dialogs. Text returned by the remote service uses the explicit lookup path because it is not part of the compiled form resources.

References: transgui.lpr• L33-47 main.pas• L52-155 restranslator.pas• L318-324 main.pas• L2460-2470

Locale-sensitive display

Language resources control interface words and messages. The operating system locale also supplies platform format settings, such as date and time patterns, so translated text and locale-aware values can appear together in the desktop interface. On macOS, the application reads those settings from the system UI locale.

References: maclocale.pas• L6-9 maclocale.pas• L173-189 transgui.lpr• L33-42

Change checklist

When these files or sections are changed, remember to consider these:

  • Add or update the matching source entry in lang/transgui.template when a user-visible resource string or form property changes.
  • Keep formatting placeholders and access-key intent aligned between the source value and each translation. These are part of the caller-facing text contract.
  • Keep the TranslationLanguage value and the file suffix aligned so the options list can find and display the resource.
  • Include the lang resources in each platform package. The executable alone cannot provide translated interface text.
  • Re-run the language update mode after new forms or resource strings are added. The maintenance scan sees forms that the application creates before it updates the files.

Important failure modes

TriggerConsequenceGuard
The selected translation file is missing or invalid.Start-up ignores the saved choice and uses locale matching or English.Keep the saved file name relative to the active lang directory and ship that file with the application.
The language directory is absent from a package.The language list contains only English and the interface cannot load a translation.Copy the language resources into the platform package under the application lang directory.
A translation changes or removes a %s or %d placeholder.A formatted message can show wrong data or fail when its caller supplies arguments.Treat placeholders as fixed parts of the source-to-translation contract.
A new source string is not added to maintained resources.The new text remains in English even when the rest of the interface is translated.Update the template and supplement language files after resource changes.
A user changes language or direction settings during a session.The current process keeps its loaded language until restart.Show and honor the restart notice before expecting the new interface language.

Key files

FileWhy to read it
restranslator.pasDefines the language file format, locale search, runtime lookup, Lazarus resource hook, and resource maintenance rules.
main.pasShows the source resource strings, start-up language loading, external text lookup, and maintenance command flow.
options.pasShows how users see available languages and save a language choice.
connoptions.pasShows the language diagnostics exposed through the interface, including the active file and language directory.
lang/transgui.templateProvides the source entry set used to create and supplement language resources.
lang/transgui.enShows the English resource shape and the source-language metadata.
lang/transgui.ruShows a translated resource with placeholders, access keys, and multi-line values.
transgui.lprShows the Lazarus application entry point and the units that make the interface and translator available.
maclocale.pasShows the platform support for reading macOS locale format settings.