Cockatrice/libcockatrice_card/libcockatrice/card/card_localization.h
Lukas Brübach e029173e29 [Card] Add a setting for the language used in card search
Localized card names and texts can now be searched too, controlled by a
'Language used in card search' toggle (English, selected card language, or
both) on the general settings page. Untranslated cards always keep matching
in English.

Removed the redundant local copy of the URL templates list in the localized
picture loader while here.
2026-09-18 12:09:20 +02:00

53 lines
No EOL
1.7 KiB
C++

#ifndef CARD_LOCALIZATION_H
#define CARD_LOCALIZATION_H
#include <QString>
#include <QStringList>
/**
* @namespace CardLocalization
* @ingroup Cards
*
* @brief Shared language metadata for localized card text and images.
*
* Lists the language codes Cockatrice can display localized card data for and
* provides human-readable names. The list is shared between Oracle (which
* imports the selected language's card data) and the client settings UI (which
* offers the language choice).
*/
/**
* @brief The card languages card search should run against.
*/
enum class CardSearchLanguage
{
English, ///< Only search the English card names and texts.
Selected, ///< Search the selected card language (untranslated cards still match in English).
Both ///< Search both the English and the selected card language names and texts.
};
namespace CardLocalization
{
/**
* @brief Language codes for which localized card data can be imported/displayed.
*
* Matches the languages Scryfall can serve localized card images for. "en" is
* always available as the default/fallback and is not listed here.
*
* @return The list of supported language codes.
*/
[[nodiscard]] const QStringList &supportedLanguages();
/**
* @brief Human-readable name for a language code.
*
* Follows the same "native name (English name)" format the UI language list
* uses (e.g. "日本語 (Japanese)"), so the English fallback is always visible.
*
* @param lang Language code (e.g. "de", "ja", "zhs").
* @return The language's native name with its English name in parentheses, or
* the code itself if it cannot be resolved.
*/
[[nodiscard]] QString languageDisplayName(const QString &lang);
} // namespace CardLocalization
#endif // CARD_LOCALIZATION_H