blob: dc4380bd44b692be0cef854c774cea3b88b14ba4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
//
// Fluid Project Internationalization code for the Fast Light Tool Kit (FLTK).
//
// Copyright 2025 by Bill Spitzak and others.
//
// This library is free software. Distribution and use rights are outlined in
// the file "COPYING" which should have been included with this file. If this
// file is missing or damaged, see the license at:
//
// https://www.fltk.org/COPYING.php
//
// Please see the following page on how to report bugs and issues:
//
// https://www.fltk.org/bugs.php
//
#include "proj/i18n.h"
#include "io/Project_Reader.h"
#include "io/Project_Writer.h"
using namespace fld;
using namespace fld::proj;
/**
Reset all project setting to create a new empty project.
*/
void I18n::reset() {
type = FLD_I18N_TYPE_NONE;
gnu_include = "<libintl.h>";
gnu_conditional = "";
gnu_function = "gettext";
gnu_static_function = "gettext_noop";
posix_include = "<nl_types.h>";
posix_conditional = "";
posix_file = "";
posix_set = "1";
}
void I18n::read(io::Project_Reader &f, const char *key) {
if (!strcmp(key, "i18n_type")) {
type = static_cast<fld::I18n_Type>(atoi(f.read_word()));
} else if (!strcmp(key, "i18n_gnu_function")) {
gnu_function = f.read_word();
} else if (!strcmp(key, "i18n_gnu_static_function")) {
gnu_static_function = f.read_word();
} else if (!strcmp(key, "i18n_pos_file")) {
posix_file = f.read_word();
} else if (!strcmp(key, "i18n_pos_set")) {
posix_set = f.read_word();
} else if (!strcmp(key, "i18n_include")) {
if (type == FLD_I18N_TYPE_GNU) {
gnu_include = f.read_word();
} else if (type == FLD_I18N_TYPE_POSIX) {
posix_include = f.read_word();
}
} else if (!strcmp(key, "i18n_conditional")) {
if (type == FLD_I18N_TYPE_GNU) {
gnu_conditional = f.read_word();
} else if (type == FLD_I18N_TYPE_POSIX) {
posix_conditional = f.read_word();
}
}
}
void I18n::write(io::Project_Writer &f) const {
if ((type != FLD_I18N_TYPE_NONE)) {
f.write_string("\ni18n_type %d", static_cast<int>(type));
switch (type) {
case FLD_I18N_TYPE_NONE:
break;
case FLD_I18N_TYPE_GNU : /* GNU gettext */
f.write_string("\ni18n_include"); f.write_word(gnu_include);
f.write_string("\ni18n_conditional"); f.write_word(gnu_conditional);
f.write_string("\ni18n_gnu_function"); f.write_word(gnu_function);
f.write_string("\ni18n_gnu_static_function"); f.write_word(gnu_static_function);
break;
case FLD_I18N_TYPE_POSIX : /* POSIX catgets */
f.write_string("\ni18n_include"); f.write_word(posix_include);
f.write_string("\ni18n_conditional"); f.write_word(posix_conditional);
if (!posix_file.empty()) {
f.write_string("\ni18n_pos_file");
f.write_word(posix_file);
}
f.write_string("\ni18n_pos_set"); f.write_word(posix_set);
break;
}
}
}
|