Files
opu/src/ui-haiku/i18n.hpp
T
yann64andClaude Opus 5.5 155545660e
CI / Linux arm64 (push) Waiting to run
CI / Linux x86_64 (push) Waiting to run
CI / ASan + UBSan (push) Waiting to run
Haiku: native Interface Kit user interface
Same workflow as the GTK interface: vehicle list, adding a vehicle by VIN,
available updates, download folder, resumable download with progress, USB
stick selection with an erase confirmation, writing, installation guide.
Also a Preferences window (folder, language, automatic new-version check),
an About window and the manual new-version check.

Worker threads post closures to the window through a non-blocking queue
(BMessenger with a zero timeout). Translations use gettext with the GTK
catalogs; the default language comes from the Locale preferences. The
executable gets its signature and version from a generated .rdef.

Validated in the Haiku R1/beta6 VM against a mock Majestic server: full
flow down to a FAT32 stick with license/, both archives and no
UpdateInfo.xml; French interface; GitHub new-version check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WDASLCiN764v685boRVYar
2026-11-29 05:56:25 +01:00

35 lines
1009 B
C++

// SPDX-License-Identifier: MIT
#pragma once
// gettext, with the same message catalogs as the GTK interface (po/).
#include <libintl.h>
#include <initializer_list>
#include <string>
#define _(text) gettext(text)
namespace openpu::haiku {
/// Replaces %1..%9 in `format` (same placeholders as Glib::ustring::compose, so the translations
/// are shared with the GTK interface).
inline std::string compose(const std::string& format, std::initializer_list<std::string> args)
{
std::string out;
out.reserve(format.size());
for (std::size_t i = 0; i < format.size(); ++i) {
const char c = format[i];
if (c == '%' && i + 1 < format.size() && format[i + 1] >= '1' && format[i + 1] <= '9') {
const auto index = static_cast<std::size_t>(format[i + 1] - '1');
if (index < args.size())
out += *(args.begin() + index);
++i;
continue;
}
out.push_back(c);
}
return out;
}
} // namespace openpu::haiku