mirror of
https://github.com/libretro/devilutionX.git
synced 2026-11-13 04:34:45 -10:00
1. Do not modify the map after loading. Instead, return string views (guaranteed to be null-terminated) from look up functions and return the key directly if not found. 2. Use an `unorded_map` instead of `map` where available (C++20). Saves a bit of RAM (~50 KiB) and improves lookup performance.
39 lines
1.2 KiB
C++
39 lines
1.2 KiB
C++
#pragma once
|
|
|
|
#include <string>
|
|
|
|
#include "utils/stdcompat/string_view.hpp"
|
|
|
|
#define _(x) LanguageTranslate(x)
|
|
#define ngettext(x, y, z) LanguagePluralTranslate(x, y, z)
|
|
#define pgettext(context, x) LanguageParticularTranslate(context, x)
|
|
#define N_(x) (x)
|
|
#define P_(context, x) (x)
|
|
|
|
bool HasTranslation(const std::string &locale);
|
|
void LanguageInitialize();
|
|
|
|
/**
|
|
* @brief Returns the translation for the given key.
|
|
*
|
|
* @return guaranteed to be null-terminated if `key` is.
|
|
*/
|
|
devilution::string_view LanguageTranslate(devilution::string_view key);
|
|
|
|
/**
|
|
* @brief Returns a singular or plural translation for the given keys and count.
|
|
*
|
|
* @return guaranteed to be null-terminated if `key` is.
|
|
*/
|
|
devilution::string_view LanguagePluralTranslate(devilution::string_view singular, devilution::string_view plural, int count);
|
|
|
|
/**
|
|
* @brief Returns the translation for the given key and context identifier.
|
|
*
|
|
* @return guaranteed to be null-terminated if `key` is.
|
|
*/
|
|
devilution::string_view LanguageParticularTranslate(devilution::string_view context, devilution::string_view message);
|
|
|
|
// Chinese and Japanese, and Korean small font is 16px instead of a 12px one for readability.
|
|
bool IsSmallFontTall();
|