FlightGear next
TranslationUnit.hxx
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2025 Florent Rougon
2// SPDX-License-Identifier: GPL-2.0-or-later
3
8
9#pragma once
10
11#include <string>
12#include <vector>
13
14#include "LanguageInfo.hxx"
15
32
34{
35public:
37
38 explicit TranslationUnit(const std::string sourceText = {},
39 const std::vector<std::string> targetTexts = {},
40 bool hasPlural = false);
41
43 std::string getSourceText() const;
45 void setSourceText(std::string text);
46
48 std::string getTargetText(int pluralFormIndex = 0) const;
49 // For sanity checks when a caller is about to use a plural form index
51 std::size_t getNumberOfTargetTexts() const;
53 void setTargetText(int pluralFormIndex, std::string text);
55 void setTargetTexts(std::vector<std::string> texts);
56
70 bool getPluralStatus() const;
76 void setPluralStatus(int hasPlural);
77
90 std::string getTranslation() const;
101 std::string getTranslation(intType cardinalNumber) const;
102
106 static void setupGhost();
107
108private:
110 std::string _sourceText;
121 std::vector<std::string> _targetTexts;
123 bool _hasPlural;
124};
Information on plural forms for the supported languages.
std::string getTargetText(int pluralFormIndex=0) const
Get the target text (translated string) associated to pluralFormIndex.
std::string getTranslation() const
Get the target text of a non-plural translation unit.
bool getPluralStatus() const
Return the plural status of a translation unit.
std::size_t getNumberOfTargetTexts() const
Return the number of target texts (plural forms) present in the object.
std::string getSourceText() const
Return the source text of the object, i.e. the “engineering English” form.
TranslationUnit(const std::string sourceText={}, const std::vector< std::string > targetTexts={}, bool hasPlural=false)
void setPluralStatus(int hasPlural)
Set the plural status of a translation unit.
void setTargetTexts(std::vector< std::string > texts)
Set all target texts at once.
void setSourceText(std::string text)
Set the source text of the object, i.e. the “engineering English” form.
static void setupGhost()
Set up a Nasal type that wraps TranslationUnit.
void setTargetText(int pluralFormIndex, std::string text)
Set the target text for the specified plural form.
flightgear::LanguageInfo::intType intType