// SPDX-License-Identifier: MIT #pragma once // gettext, with the same message catalogs as the GTK interface (po/). #include #include #include #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 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(format[i + 1] - '1'); if (index < args.size()) out += *(args.begin() + index); ++i; continue; } out.push_back(c); } return out; } } // namespace openpu::haiku