OpenTTD Source: src/strgen/strgen.cpp Source File

OpenTTD Source 14.0-beta1

strgen.cpp
Go to the documentation of this file.
1 /*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6 */
7
10 #include "../stdafx.h"
11 #include "../core/endian_func.hpp"
12 #include "../core/mem_func.hpp"
13 #include "../error_func.h"
14 #include "../string_func.h"
15 #include "../strings_type.h"
16 #include "../misc/getoptdata.h"
17 #include "../table/control_codes.h"
18 #include "../3rdparty/fmt/std.h"
19
20 #include "strgen.h"
21
22 #include <filesystem>
23 #include <fstream>
24
25 #include "../table/strgen_tables.h"
26
27 #include "../safeguards.h"
28
29
30 #ifdef _MSC_VER
31 # define LINE_NUM_FMT(s) "{} ({}): warning: {} (" s ")\n"
32 #else
33 # define LINE_NUM_FMT(s) "{}:{}: " s ": {}\n"
34 #endif
35
36 void StrgenWarningI(const std::string &msg)
37 {
38 if (_show_todo > 0) {
39 fmt::print(stderr, LINE_NUM_FMT("warning"), _file, _cur_line, msg);
40 } else {
41 fmt::print(stderr, LINE_NUM_FMT("info"), _file, _cur_line, msg);
42 }
43 _warnings++;
44 }
45
46 void StrgenErrorI(const std::string &msg)
47 {
48 fmt::print(stderr, LINE_NUM_FMT("error"), _file, _cur_line, msg);
49 _errors++;
50 }
51
52 [[noreturn]] void StrgenFatalI(const std::string &msg)
53 {
54 fmt::print(stderr, LINE_NUM_FMT("FATAL"), _file, _cur_line, msg);
55 #ifdef _MSC_VER
56 fmt::print(stderr, LINE_NUM_FMT("warning"), _file, _cur_line, "language is not compiled");
57 #endif
58 throw std::exception();
59 }
60
61 [[noreturn]] void FatalErrorI(const std::string &msg)
62 {
63 fmt::print(stderr, LINE_NUM_FMT("FATAL"), _file, _cur_line, msg);
64 #ifdef _MSC_VER
65 fmt::print(stderr, LINE_NUM_FMT("warning"), _file, _cur_line, "language is not compiled");
66 #endif
67 exit(2);
68 }
69
71 struct FileStringReader : StringReader {
72 std::ifstream input_stream;
73
81 FileStringReader(StringData &data, const std::filesystem::path &file, bool master, bool translation) :
82 StringReader(data, file.generic_string(), master, translation)
83 {
84 this->input_stream.open(file, std::ifstream::binary);
85 }
86
87 std::optional<std::string> ReadLine() override
88 {
89 std::string result;
90 if (!std::getline(this->input_stream, result)) return std::nullopt;
91 return result;
92 }
93
94 void HandlePragma(char *str) override;
95
96 void ParseFile() override
97 {
98 this->StringReader::ParseFile();
99
100 if (StrEmpty(_lang.name) || StrEmpty(_lang.own_name) || StrEmpty(_lang.isocode)) {
101 FatalError("Language must include ##name, ##ownname and ##isocode");
102 }
103 }
104 };
105
106 void FileStringReader::HandlePragma(char *str)
107 {
108 if (!memcmp(str, "id ", 3)) {
109 this->data.next_string_id = std::strtoul(str + 3, nullptr, 0);
110 } else if (!memcmp(str, "name ", 5)) {
111 strecpy(_lang.name, str + 5, lastof(_lang.name));
112 } else if (!memcmp(str, "ownname ", 8)) {
113 strecpy(_lang.own_name, str + 8, lastof(_lang.own_name));
114 } else if (!memcmp(str, "isocode ", 8)) {
115 strecpy(_lang.isocode, str + 8, lastof(_lang.isocode));
116 } else if (!memcmp(str, "textdir ", 8)) {
117 if (!memcmp(str + 8, "ltr", 3)) {
118 _lang.text_dir = TD_LTR;
119 } else if (!memcmp(str + 8, "rtl", 3)) {
120 _lang.text_dir = TD_RTL;
121 } else {
122 FatalError("Invalid textdir {}", str + 8);
123 }
124 } else if (!memcmp(str, "digitsep ", 9)) {
125 str += 9;
126 strecpy(_lang.digit_group_separator, strcmp(str, "{NBSP}") == 0 ? NBSP : str, lastof(_lang.digit_group_separator));
127 } else if (!memcmp(str, "digitsepcur ", 12)) {
128 str += 12;
129 strecpy(_lang.digit_group_separator_currency, strcmp(str, "{NBSP}") == 0 ? NBSP : str, lastof(_lang.digit_group_separator_currency));
130 } else if (!memcmp(str, "decimalsep ", 11)) {
131 str += 11;
132 strecpy(_lang.digit_decimal_separator, strcmp(str, "{NBSP}") == 0 ? NBSP : str, lastof(_lang.digit_decimal_separator));
133 } else if (!memcmp(str, "winlangid ", 10)) {
134 const char *buf = str + 10;
135 long langid = std::strtol(buf, nullptr, 16);
136 if (langid > (long)UINT16_MAX || langid < 0) {
137 FatalError("Invalid winlangid {}", buf);
138 }
139 _lang.winlangid = (uint16_t)langid;
140 } else if (!memcmp(str, "grflangid ", 10)) {
141 const char *buf = str + 10;
142 long langid = std::strtol(buf, nullptr, 16);
143 if (langid >= 0x7F || langid < 0) {
144 FatalError("Invalid grflangid {}", buf);
145 }
146 _lang.newgrflangid = (uint8_t)langid;
147 } else if (!memcmp(str, "gender ", 7)) {
148 if (this->master) FatalError("Genders are not allowed in the base translation.");
149 char *buf = str + 7;
150
151 for (;;) {
152 const char *s = ParseWord(&buf);
153
154 if (s == nullptr) break;
155 if (_lang.num_genders >= MAX_NUM_GENDERS) FatalError("Too many genders, max {}", MAX_NUM_GENDERS);
156 strecpy(_lang.genders[_lang.num_genders], s, lastof(_lang.genders[_lang.num_genders]));
157 _lang.num_genders++;
158 }
159 } else if (!memcmp(str, "case ", 5)) {
160 if (this->master) FatalError("Cases are not allowed in the base translation.");
161 char *buf = str + 5;
162
163 for (;;) {
164 const char *s = ParseWord(&buf);
165
166 if (s == nullptr) break;
167 if (_lang.num_cases >= MAX_NUM_CASES) FatalError("Too many cases, max {}", MAX_NUM_CASES);
168 strecpy(_lang.cases[_lang.num_cases], s, lastof(_lang.cases[_lang.num_cases]));
169 _lang.num_cases++;
170 }
171 } else {
172 StringReader::HandlePragma(str);
173 }
174 }
175
176 bool CompareFiles(const std::filesystem::path &path1, const std::filesystem::path &path2)
177 {
178 /* Check for equal size, but ignore the error code for cases when a file does not exist. */
179 std::error_code error_code;
180 if (std::filesystem::file_size(path1, error_code) != std::filesystem::file_size(path2, error_code)) return false;
181
182 std::ifstream stream1(path1, std::ifstream::binary);
183 std::ifstream stream2(path2, std::ifstream::binary);
184
185 return std::equal(std::istreambuf_iterator<char>(stream1.rdbuf()),
186 std::istreambuf_iterator<char>(),
187 std::istreambuf_iterator<char>(stream2.rdbuf()));
188 }
189
191 struct FileWriter {
192 std::ofstream output_stream;
193 const std::filesystem::path path;
194
200 FileWriter(const std::filesystem::path &path, std::ios_base::openmode openmode) : path(path)
201 {
202 this->output_stream.open(path, openmode);
203 }
204
206 void Finalise()
207 {
208 this->output_stream.close();
209 }
210
212 virtual ~FileWriter()
213 {
214 /* If we weren't closed an exception was thrown, so remove the temporary file. */
215 if (this->output_stream.is_open()) {
216 this->output_stream.close();
217 std::filesystem::remove(this->path);
218 }
219 }
220 };
221
222 struct HeaderFileWriter : HeaderWriter, FileWriter {
224 const std::filesystem::path real_path;
226 int prev;
227 uint total_strings;
228
233 HeaderFileWriter(const std::filesystem::path &path) : FileWriter("tmp.xxx", std::ofstream::out),
234 real_path(path), prev(0), total_strings(0)
235 {
236 this->output_stream << "/* This file is automatically generated. Do not modify */\n\n";
237 this->output_stream << "#ifndef TABLE_STRINGS_H\n";
238 this->output_stream << "#define TABLE_STRINGS_H\n";
239 }
240
241 void WriteStringID(const std::string &name, int stringid) override
242 {
243 if (prev + 1 != stringid) this->output_stream << "\n";
244 fmt::print(this->output_stream, "static const StringID {} = 0x{:X};\n", name, stringid);
245 prev = stringid;
246 total_strings++;
247 }
248
249 void Finalise(const StringData &data) override
250 {
251 /* Find the plural form with the most amount of cases. */
252 int max_plural_forms = 0;
253 for (uint i = 0; i < lengthof(_plural_forms); i++) {
254 max_plural_forms = std::max(max_plural_forms, _plural_forms[i].plural_count);
255 }
256
257 fmt::print(this->output_stream,
258 "\n"
259 "static const uint LANGUAGE_PACK_VERSION = 0x{:X};\n"
260 "static const uint LANGUAGE_MAX_PLURAL = {};\n"
261 "static const uint LANGUAGE_MAX_PLURAL_FORMS = {};\n"
262 "static const uint LANGUAGE_TOTAL_STRINGS = {};\n"
263 "\n",
264 data.Version(), lengthof(_plural_forms), max_plural_forms, total_strings
265 );
266
267 this->output_stream << "#endif /* TABLE_STRINGS_H */\n";
268
269 this->FileWriter::Finalise();
270
271 std::error_code error_code;
272 if (CompareFiles(this->path, this->real_path)) {
273 /* files are equal. tmp.xxx is not needed */
274 std::filesystem::remove(this->path, error_code); // Just ignore the error
275 } else {
276 /* else rename tmp.xxx into filename */
277 # if defined(_WIN32)
278 std::filesystem::remove(this->real_path, error_code); // Just ignore the error, file probably doesn't exist
279 # endif
280 std::filesystem::rename(this->path, this->real_path, error_code);
281 if (error_code) FatalError("rename({}, {}) failed: {}", this->path, this->real_path, error_code.message());
282 }
283 }
284 };
285
287 struct LanguageFileWriter : LanguageWriter, FileWriter {
292 LanguageFileWriter(const std::filesystem::path &path) : FileWriter(path, std::ofstream::binary | std::ofstream::out)
293 {
294 }
295
296 void WriteHeader(const LanguagePackHeader *header) override
297 {
298 this->Write((const byte *)header, sizeof(*header));
299 }
300
301 void Finalise() override
302 {
303 this->output_stream.put(0);
304 this->FileWriter::Finalise();
305 }
306
307 void Write(const byte *buffer, size_t length) override
308 {
309 this->output_stream.write((const char *)buffer, length);
310 }
311 };
312
314 static const OptionData _opts[] = {
315 GETOPT_GENERAL('C', '\0', "-export-commands", ODF_NO_VALUE),
316 GETOPT_GENERAL('L', '\0', "-export-plurals", ODF_NO_VALUE),
317 GETOPT_GENERAL('P', '\0', "-export-pragmas", ODF_NO_VALUE),
318 GETOPT_NOVAL( 't', "--todo"),
319 GETOPT_NOVAL( 'w', "--warning"),
320 GETOPT_NOVAL( 'h', "--help"),
321 GETOPT_GENERAL('h', '?', nullptr, ODF_NO_VALUE),
322 GETOPT_VALUE( 's', "--source_dir"),
323 GETOPT_VALUE( 'd', "--dest_dir"),
324 GETOPT_END(),
325 };
326
327 int CDECL main(int argc, char *argv[])
328 {
329 std::filesystem::path src_dir(".");
330 std::filesystem::path dest_dir;
331
332 GetOptData mgo(argc - 1, argv + 1, _opts);
333 for (;;) {
334 int i = mgo.GetOpt();
335 if (i == -1) break;
336
337 switch (i) {
338 case 'C':
339 fmt::print("args\tflags\tcommand\treplacement\n");
340 for (const CmdStruct *cs = _cmd_structs; cs < endof(_cmd_structs); cs++) {
341 char flags;
342 if (cs->proc == EmitGender) {
343 flags = 'g'; // Command needs number of parameters defined by number of genders
344 } else if (cs->proc == EmitPlural) {
345 flags = 'p'; // Command needs number of parameters defined by plural value
346 } else if (cs->flags & C_DONTCOUNT) {
347 flags = 'i'; // Command may be in the translation when it is not in base
348 } else {
349 flags = '0'; // Command needs no parameters
350 }
351 fmt::print("{}\t{:c}\t\"{}\"\t\"{}\"\n", cs->consumes, flags, cs->cmd, strstr(cs->cmd, "STRING") ? "STRING" : cs->cmd);
352 }
353 return 0;
354
355 case 'L':
356 fmt::print("count\tdescription\tnames\n");
357 for (const PluralForm *pf = _plural_forms; pf < endof(_plural_forms); pf++) {
358 fmt::print("{}\t\"{}\"\t{}\n", pf->plural_count, pf->description, pf->names);
359 }
360 return 0;
361
362 case 'P':
363 fmt::print("name\tflags\tdefault\tdescription\n");
364 for (size_t j = 0; j < lengthof(_pragmas); j++) {
365 fmt::print("\"{}\"\t{}\t\"{}\"\t\"{}\"\n",
366 _pragmas[j][0], _pragmas[j][1], _pragmas[j][2], _pragmas[j][3]);
367 }
368 return 0;
369
370 case 't':
371 _show_todo |= 1;
372 break;
373
374 case 'w':
375 _show_todo |= 2;
376 break;
377
378 case 'h':
379 fmt::print(
380 "strgen\n"
381 " -t | --todo replace any untranslated strings with '<TODO>'\n"
382 " -w | --warning print a warning for any untranslated strings\n"
383 " -h | -? | --help print this help message and exit\n"
384 " -s | --source_dir search for english.txt in the specified directory\n"
385 " -d | --dest_dir put output file in the specified directory, create if needed\n"
386 " -export-commands export all commands and exit\n"
387 " -export-plurals export all plural forms and exit\n"
388 " -export-pragmas export all pragmas and exit\n"
389 " Run without parameters and strgen will search for english.txt and parse it,\n"
390 " creating strings.h. Passing an argument, strgen will translate that language\n"
391 " file using english.txt as a reference and output <language>.lng.\n"
392 );
393 return 0;
394
395 case 's':
396 src_dir = mgo.opt;
397 break;
398
399 case 'd':
400 dest_dir = mgo.opt;
401 break;
402
403 case -2:
404 fmt::print(stderr, "Invalid arguments\n");
405 return 0;
406 }
407 }
408
409 if (dest_dir.empty()) dest_dir = src_dir; // if dest_dir is not specified, it equals src_dir
410
411 try {
412 /* strgen has two modes of operation. If no (free) arguments are passed
413 * strgen generates strings.h to the destination directory. If it is supplied
414 * with a (free) parameter the program will translate that language to destination
415 * directory. As input english.txt is parsed from the source directory */
416 if (mgo.numleft == 0) {
417 std::filesystem::path input_path = src_dir;
418 input_path /= "english.txt";
419
420 /* parse master file */
421 StringData data(TEXT_TAB_END);
422 FileStringReader master_reader(data, input_path, true, false);
423 master_reader.ParseFile();
424 if (_errors != 0) return 1;
425
426 /* write strings.h */
427 std::filesystem::path output_path = dest_dir;
428 std::filesystem::create_directories(dest_dir);
429 output_path /= "strings.h";
430
431 HeaderFileWriter writer(output_path);
432 writer.WriteHeader(data);
433 writer.Finalise(data);
434 if (_errors != 0) return 1;
435 } else if (mgo.numleft >= 1) {
436 std::filesystem::path input_path = src_dir;
437 input_path /= "english.txt";
438
439 StringData data(TEXT_TAB_END);
440 /* parse master file and check if target file is correct */
441 FileStringReader master_reader(data, input_path, true, false);
442 master_reader.ParseFile();
443
444 for (int i = 0; i < mgo.numleft; i++) {
445 data.FreeTranslation();
446
447 std::filesystem::path lang_file = mgo.argv[i];
448 FileStringReader translation_reader(data, lang_file, false, lang_file.filename() != "english.txt");
449 translation_reader.ParseFile(); // target file
450 if (_errors != 0) return 1;
451
452 /* get the targetfile, strip any directories and append to destination path */
453 std::filesystem::path output_file = dest_dir;
454 output_file /= lang_file.filename();
455 output_file.replace_extension("lng");
456
457 LanguageFileWriter writer(output_file);
458 writer.WriteLang(data);
459 writer.Finalise();
460
461 /* if showing warnings, print a summary of the language */
462 if ((_show_todo & 2) != 0) {
463 fmt::print("{} warnings and {} errors for {}\n", _warnings, _errors, output_file);
464 }
465 }
466 }
467 } catch (...) {
468 return 2;
469 }
470
471 return 0;
472 }
_file
const char * _file
The filename of the input, so we can refer to it in errors/warnings.
Definition: strgen_base.cpp:29
LanguageFileWriter::WriteHeader
void WriteHeader(const LanguagePackHeader *header) override
Write the header metadata.
Definition: strgen.cpp:296
LanguagePackHeader::text_dir
byte text_dir
default direction of the text
Definition: language.h:42
StringReader::HandlePragma
virtual void HandlePragma(char *str)
Handle the pragma of the file.
Definition: strgen_base.cpp:729
CompareFiles
static bool CompareFiles(const char *n1, const char *n2)
Compare two files for identity.
Definition: settingsgen.cpp:356
LanguageFileWriter::Write
void Write(const byte *buffer, size_t length) override
Write a number of bytes.
Definition: strgen.cpp:307
TEXT_TAB_END
@ TEXT_TAB_END
End of language files.
Definition: strings_type.h:38
FileWriter::output_stream
std::ofstream output_stream
The stream to write all the output to.
Definition: strgen.cpp:192
LanguagePackHeader::num_cases
uint8_t num_cases
the number of cases of this language
Definition: language.h:54
_opts
static const OptionData _opts[]
Options of strgen.
Definition: strgen.cpp:314
TD_LTR
@ TD_LTR
Text is written left-to-right by default.
Definition: strings_type.h:23
LanguageFileWriter
Class for writing a language to disk.
Definition: strgen.cpp:287
PluralForm
Description of a plural form.
Definition: strgen_tables.h:161
LanguageFileWriter::LanguageFileWriter
LanguageFileWriter(const std::filesystem::path &path)
Open a file to write to.
Definition: strgen.cpp:292
GETOPT_VALUE
#define GETOPT_VALUE(shortname, longname)
Short option with value.
Definition: getoptdata.h:76
HeaderWriter
Base class for writing the header, i.e.
Definition: strgen.h:87
HeaderFileWriter::HeaderFileWriter
HeaderFileWriter(const std::filesystem::path &path)
Open a file to write to.
Definition: strgen.cpp:233
LanguagePackHeader::genders
char genders[MAX_NUM_GENDERS][CASE_GENDER_LEN]
the genders used by this translation
Definition: language.h:57
LanguagePackHeader::num_genders
uint8_t num_genders
the number of genders of this language
Definition: language.h:53
LanguagePackHeader::newgrflangid
uint8_t newgrflangid
newgrf language id
Definition: language.h:52
_lang
LanguagePackHeader _lang
Header information about a language.
Definition: strgen_base.cpp:32
C_DONTCOUNT
@ C_DONTCOUNT
These commands aren't counted for comparison.
Definition: strgen_tables.h:14
_cur_line
int _cur_line
The current line we're parsing in the input file.
Definition: strgen_base.cpp:30
FileStringReader::HandlePragma
void HandlePragma(char *str) override
Handle the pragma of the file.
Definition: strgen.cpp:106
StrEmpty
bool StrEmpty(const char *s)
Check if a string buffer is empty.
Definition: string_func.h:56
HeaderFileWriter::prev
int prev
The previous string ID that was printed.
Definition: strgen.cpp:226
StringReader::master
bool master
Are we reading the master file?
Definition: strgen.h:61
StringData::next_string_id
size_t next_string_id
The next string ID to allocate.
Definition: strgen.h:46
NBSP
#define NBSP
A non-breaking space.
Definition: string_type.h:16
FileWriter::FileWriter
FileWriter(const std::filesystem::path &path, std::ios_base::openmode openmode)
Open a file to write to.
Definition: strgen.cpp:200
LanguagePackHeader::cases
char cases[MAX_NUM_CASES][CASE_GENDER_LEN]
the cases used by this translation
Definition: language.h:58
StringData::Version
uint Version() const
Make a hash of the file to get a unique "version number".
Definition: strgen_base.cpp:128
MAX_NUM_CASES
static const uint8_t MAX_NUM_CASES
Maximum number of supported cases.
Definition: language.h:21
HeaderFileWriter
Definition: strgen.cpp:222
StringData
Information about the currently known strings.
Definition: strgen.h:41
GETOPT_NOVAL
#define GETOPT_NOVAL(shortname, longname)
Short option without value.
Definition: getoptdata.h:69
HeaderFileWriter::WriteStringID
void WriteStringID(const std::string &name, int stringid) override
Write the string ID.
Definition: strgen.cpp:241
GETOPT_END
#define GETOPT_END()
Option terminator.
Definition: getoptdata.h:107
FatalErrorI
void FatalErrorI(const std::string &msg)
Error handling for fatal non-user errors.
Definition: strgen.cpp:61
strgen.h
GETOPT_GENERAL
#define GETOPT_GENERAL(id, shortname, longname, flags)
General macro for creating an option.
Definition: getoptdata.h:62
MAX_NUM_GENDERS
static const uint8_t MAX_NUM_GENDERS
Maximum number of supported genders.
Definition: language.h:20
LanguagePackHeader::name
char name[32]
the international name of this language
Definition: language.h:29
HeaderFileWriter::Finalise
void Finalise(const StringData &data) override
Finalise writing the file.
Definition: strgen.cpp:249
CmdStruct
Definition: strgen_tables.h:23
FileStringReader
A reader that simply reads using fopen.
Definition: strgen.cpp:71
OptionData
Data of an option.
Definition: getoptdata.h:22
LanguagePackHeader::digit_decimal_separator
char digit_decimal_separator[8]
Decimal separator.
Definition: language.h:39
LanguagePackHeader::own_name
char own_name[32]
the localized name of this language
Definition: language.h:30
GetOptData
Data storage for parsing command line options.
Definition: getoptdata.h:30
LanguagePackHeader::isocode
char isocode[16]
the ISO code for the language (not country code)
Definition: language.h:31
main
int CDECL main(int argc, char *argv[])
And the main program (what else?)
Definition: settingsgen.cpp:433
FileStringReader::ParseFile
void ParseFile() override
Start parsing the file.
Definition: strgen.cpp:96
_pragmas
static const char *const _pragmas[][4]
All pragmas used.
Definition: strgen_tables.h:202
endof
#define endof(x)
Get the end element of an fixed size array.
Definition: stdafx.h:308
FileStringReader::ReadLine
std::optional< std::string > ReadLine() override
Read a single line from the source of strings.
Definition: strgen.cpp:87
StringReader::data
StringData & data
The data to fill during reading.
Definition: strgen.h:59
HeaderFileWriter::real_path
const std::filesystem::path real_path
The real path we eventually want to write to.
Definition: strgen.cpp:224
LanguagePackHeader::digit_group_separator_currency
char digit_group_separator_currency[8]
Thousand separator used for currencies.
Definition: language.h:37
StringReader::translation
bool translation
Are we reading a translation, implies !master. However, the base translation will have this false.
Definition: strgen.h:62
StringReader::ParseFile
virtual void ParseFile()
Start parsing the file.
Definition: strgen_base.cpp:746
lengthof
#define lengthof(x)
Return the length of an fixed size array.
Definition: stdafx.h:300
LanguageWriter
Base class for all language writers.
Definition: strgen.h:108
LanguagePackHeader::digit_group_separator
char digit_group_separator[8]
Thousand separator used for anything not currencies.
Definition: language.h:35
LanguagePackHeader::winlangid
uint16_t winlangid
Windows language ID: Windows cannot and will not convert isocodes to something it can use to determin...
Definition: language.h:51
FileStringReader::FileStringReader
FileStringReader(StringData &data, const std::filesystem::path &file, bool master, bool translation)
Create the reader.
Definition: strgen.cpp:81
strecpy
char * strecpy(char *dst, const char *src, const char *last)
Copies characters from one buffer to another.
Definition: string.cpp:65
FileWriter::~FileWriter
virtual ~FileWriter()
Make sure the file is closed.
Definition: strgen.cpp:212
FileWriter::Finalise
void Finalise()
Finalise the writing.
Definition: strgen.cpp:206
FileWriter::path
const std::filesystem::path path
The file name we're writing to.
Definition: strgen.cpp:193
lastof
#define lastof(x)
Get the last element of an fixed size array.
Definition: stdafx.h:316
_plural_forms
static const PluralForm _plural_forms[]
All plural forms used.
Definition: strgen_tables.h:171
LanguageFileWriter::Finalise
void Finalise() override
Finalise writing the file.
Definition: strgen.cpp:301
ODF_NO_VALUE
@ ODF_NO_VALUE
A plain option (no value attached to it).
Definition: getoptdata.h:15
TD_RTL
@ TD_RTL
Text is written right-to-left by default.
Definition: strings_type.h:24
StringReader
Helper for reading strings.
Definition: strgen.h:58
StringReader::file
const std::string file
The file we are reading.
Definition: strgen.h:60
LanguagePackHeader
Header of a language file.
Definition: language.h:24
FileWriter
Yes, simply writing to a file.
Definition: saveload.cpp:2201