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
|
/*
* SPDX-FileCopyrightText: 2025 Felix Morgner <felix.morgner@gmail.com>
* SPDX-License-Identifier: LGPL-2.1-only
*/
#include "messages.hpp"
#include <catch2/catch_test_macros.hpp>
#include <catch2/generators/catch_generators.hpp>
#include <libintl.h>
#include <clocale>
#include <format>
#include <utility>
#define LABEL(varname) \
std::pair \
{ \
#varname, varname \
}
namespace Turns::gui::tests
{
SCENARIO("Text strings are translated")
{
auto locale = GENERATE("de_CH.UTF-8", "de_DE.UTF-8", "de_AT.UTF-8");
GIVEN(std::format("The locale '{}' is active", locale))
{
setlocale(LC_ALL, locale);
auto [label, variable] = GENERATE(LABEL(message::add_participant),
LABEL(message::cancel),
LABEL(message::clear),
LABEL(message::delete_participant),
LABEL(message::disposition),
LABEL(message::disposition_colors),
LABEL(message::edit_participant),
LABEL(message::end_turn_order),
LABEL(message::finish),
LABEL(message::flow),
LABEL(message::friendly),
LABEL(message::hostile),
LABEL(message::main_menu),
LABEL(message::mark_as_defeated),
LABEL(message::name),
LABEL(message::new_turn_order_file_name),
LABEL(message::next_participant),
LABEL(message::no_active_turn_order),
LABEL(message::open),
LABEL(message::preferences),
LABEL(message::preferences_mnemonic),
LABEL(message::previous_participant),
LABEL(message::priority),
LABEL(message::priority_number),
LABEL(message::question_clear_turn_order),
LABEL(message::quit),
LABEL(message::reset),
LABEL(message::save),
LABEL(message::save_as),
LABEL(message::saving_failed_format),
LABEL(message::secret),
LABEL(message::skip_defeated),
LABEL(message::start_turn_order),
LABEL(message::stop),
LABEL(message::stop_and_clear),
LABEL(message::stop_turn_order),
LABEL(message::successfully_opened_format),
LABEL(message::successfully_saved_format),
LABEL(message::round_number),
LABEL(message::turns),
LABEL(message::turns_files));
THEN(std::format("{} is translated", label))
{
/* gettext will return it's argument if there is no translation found in any of the currently active catalogues. Therefore, if no
* translation has been found, the pointer comparison will yield true. Otherwise, a different pointer will be returned, indicating that
* a translation was found.*/
REQUIRE_FALSE(gettext(variable) == variable);
}
}
}
} // namespace Turns::gui::tests
|