1#ifndef NANOMMO_CLIENT_TRANSLATIONS_H_
2#define NANOMMO_CLIENT_TRANSLATIONS_H_
12#include "absl/status/status.h"
13#include "absl/status/statusor.h"
28 static absl::StatusOr<PluralRule>
Parse(std::string_view
forms);
30 int forms()
const {
return forms_; }
33 int Form(uint64_t n)
const;
37 std::string plural_ =
"n != 1";
49 static absl::StatusOr<Catalog>
Parse(std::string_view po);
54 static absl::StatusOr<Catalog>
PseudoFrom(std::string_view pot);
57 const char*
Find(std::string_view context, std::string_view text)
const;
60 const char*
Find(std::string_view context, std::string_view one,
66 std::map<std::string, std::vector<std::string>, std::less<>> translations_;
71std::string
Pseudo(std::string_view english);
81inline constexpr std::string_view
kPseudo =
"pseudo";
96absl::Status
UseLanguage(std::string_view code,
const std::string& folder);
101const char*
Tr(
const char* text);
105const char*
Tr(std::string_view context,
const char* text);
108const char*
TrN(
const char* one,
const char* many, uint64_t n);
109const char*
TrN(std::string_view context,
const char* one,
const char* many,
114const char*
TrLabel(
const char* label);
119constexpr const char*
N_(
const char* text) {
return text; }
120constexpr const char*
N_(
const char* ,
const char* text) {
static absl::StatusOr< Catalog > Parse(std::string_view po)
const char * Find(std::string_view context, std::string_view text) const
The translation, or null for one there isn't.
static absl::StatusOr< Catalog > PseudoFrom(std::string_view pot)
static absl::StatusOr< PluralRule > Parse(std::string_view forms)
int Form(uint64_t n) const
The form for the count, from 0.
PluralRule()=default
English's: one form for 1, and the other for any other count.
constexpr const char * N_(const char *text)
std::string Pseudo(std::string_view english)
The English made over for the pseudo-language: "[Șéțțîñgș ~~~]".
constexpr std::array< Language, 3 > kLanguages
const char * Tr(const char *text)
const char * TrN(const char *one, const char *many, uint64_t n)
The form for the count: in English, one for 1 and many for the rest.
const char * TrLabel(const char *label)
constexpr std::string_view kPseudo
The pseudo-language's code: it's made from the template, nanommo.pot.
std::string LanguageFolder()
Where the PO files are, next to the client.
absl::Status UseLanguage(std::string_view code, const std::string &folder)