#pragma once #include #include class QTranslator; // Installs the translation matching the language preference, and swaps it when // the user picks another one on the Settings screen. // // The translation files are ordinary Qt .qm catalogues, looked up as // "translations/pacmanager_.qm" in, in order: // // 1. /translations (user's own, survives an update); // 2. /translations (next to the config); // 3. /translations (running from a build tree). // // A code with no .qm on any of those paths simply stays untranslated: the // interface is written in French, which is what apply() falls back to. That is // deliberate — the setting is the plumbing, and shipping catalogues is a // translation pass of its own. class LanguageManager { public: // Resolves "system" to the desktop's language and falls back to the // interface's own language when the desktop asks for something no catalogue // covers. static QString resolve(const QString& code); // True when a catalogue is actually installed for `code`, so the Settings // screen can say so instead of pretending a choice will change something. static bool isTranslationAvailable(const QString& code); // Where a catalogue is looked up, for the screen to display. static QString searchPathHint(); // Installs the catalogue for `code` (see resolve) and asks every widget to // retranslate itself. Returns true when a catalogue was installed. static bool apply(const QString& code); // Catalogue currently installed, empty when the interface is untranslated. static QString activeCode(); // Directories actually searched, in order, existing ones only. static QStringList searchPaths(); };