mirror of
https://github.com/diasurgical/DevilutionX.git
synced 2026-10-12 11:00:04 +00:00
- `fmt::format` with literal format strings -> `std::format`. - `fmt::format(fmt::runtime(...))` -> `FormatRuntime` in the new `utils/format.hpp`, a std::vformat wrapper that is also safe under the P2905 lvalue requirement of `std::make_format_args`. - `fmt::dynamic_format_arg_store` (Lua logging) -> a small hand-rolled per-field formatter over `std::variant`, returning `std::expected`. - `fmt::format_int` -> `std::to_chars`. - `fmt::join` -> manual joins at the two call sites. - SDL_audiolib: new patch that rewrites aulib_log.h to use std::format and drops the fmt dependency from its CMakeLists. - The `-static-libstdc++` guard now keys off `DEVILUTIONX_STATIC_SDL_AUDIOLIB` instead of `DEVILUTIONX_STATIC_LIBFMT`. - libfmt removed from CMake, vcpkg, Brewfile, CI workflows, Dockerfiles, packaging scripts, UWP project, and docs. - macOS bumped to 13.3+, iOS to 16.3+ (required for `<format>`) - Amiga m68k: provide `__cmpdf2`, which is missing from the hard-float libgcc multilib but referenced via libstdc++'s long double paths. Co-Authored-By: Claude Fable 5 <[email protected]>
32 lines
1.2 KiB
C++
32 lines
1.2 KiB
C++
#include "lua/modules/i18n.hpp"
|
|
|
|
#include <string_view>
|
|
|
|
#include <sol/sol.hpp>
|
|
|
|
#include "lua/metadoc.hpp"
|
|
#include "utils/format.hpp"
|
|
#include "utils/language.h"
|
|
|
|
namespace devilution {
|
|
|
|
sol::table LuaI18nModule(sol::state_view &lua)
|
|
{
|
|
sol::table table = lua.create_table();
|
|
LuaSetDocFn(table, "language_code", "()",
|
|
"Returns the current language code", GetLanguageCode);
|
|
LuaSetDocFn(table, "translate", "(text: string)",
|
|
"Translates the given string", [](const char *key) { return LanguageTranslate(key); });
|
|
LuaSetDocFn(table, "plural_translate", "(singular: string, plural: string, count: integer)",
|
|
"Returns a singular or plural translation for the given keys and count", [](const char *singular, std::string_view plural, int count) {
|
|
return FormatRuntime(LanguagePluralTranslate(singular, plural, count), count);
|
|
});
|
|
LuaSetDocFn(table, "particular_translate", "(context: string, text: string)",
|
|
"Returns the translation for the given context identifier and key.", LanguageParticularTranslate);
|
|
LuaSetDocFn(table, "is_small_font_tall", "()",
|
|
"Whether the language's small font is tall (16px)", IsSmallFontTall);
|
|
return table;
|
|
}
|
|
|
|
} // namespace devilution
|