Audacity 3.2.0
Internat.h
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 Internat.h
6
7 Markus Meyer
8 Dominic Mazzoni (Mac OS X code)
9
10**********************************************************************/
11
12#ifndef __AUDACITY_INTERNAT__
13#define __AUDACITY_INTERNAT__
14
15#include <vector>
16#include <wx/longlong.h>
17
18#include "TranslatableString.h"
19
20class wxArrayString;
21class wxArrayStringEx;
22
23extern STRINGS_API const wxString& GetCustomTranslation(const wxString& str1 );
24extern STRINGS_API const wxString& GetCustomSubstitution(const wxString& str1 );
25
26// Marks string for substitution only.
27#define _TS( s ) GetCustomSubstitution( s )
28
29// Marks strings for extraction only... use .Translate() to translate.
30// '&', preceding menu accelerators, should NOT occur in the argument.
31#define XO(s) (TranslatableString{ wxT(s), {} })
32
33// Alternative taking a second context argument. A context is a string literal,
34// which is not translated, but serves to disambiguate uses of the first string
35// that might need differing translations, such as "Light" meaning not-heavy in
36// one place but not-dark elsewhere.
37#define XC(s, c) (TranslatableString{ wxT(s), {} }.Context(c))
38
39// Marks strings for extraction only, where '&', preceding menu accelerators, MAY
40// occur.
41// For now, expands exactly as macro XO does, but in future there will be a
42// type distinction - for example XXO should be used for menu item names that
43// might use the & character for shortcuts.
44#define XXO(s) XO(s)
45
46// Corresponds to XC as XXO does to XO
47#define XXC(s, c) XC(s, c)
48
49#ifdef _
50 #undef _
51#endif
52
53#if defined( _DEBUG )
54 // Force a crash if you misuse _ in a static initializer, so that translation
55 // is looked up too early and not found.
56
57 #ifdef __WXMSW__
58
59 extern "C" __declspec(dllimport) void __stdcall DebugBreak();
60 #define _(s) ((wxTranslations::Get() || (DebugBreak(), true)), \
61 GetCustomTranslation((s)))
62
63 #else
64
65 #include <signal.h>
66 // Raise a signal because it's even too early to use wxASSERT for this.
67 #define _(s) ((wxTranslations::Get() || raise(SIGTRAP)), \
68 GetCustomTranslation((s)))
69
70 #endif
71
72#else
73 #define _(s) GetCustomTranslation((s))
74#endif
75
76#ifdef XP
77 #undef XP
78#endif
79
80
81// The two string arguments will go to the .pot file, as
82// msgid sing
83// msgid_plural plural
84//
85// (You must use plain string literals. Do not use _() or wxT() or L prefix,
86// which (intentionally) will fail to compile. The macro inserts wxT).
87//
88// Note too: The i18n-hint comment must be on the line preceding the first
89// string. That might be inside the parentheses of the macro call.
90//
91// The macro call is then followed by a sequence of format arguments in
92// parentheses. The third argument of the macro call is the zero-based index
93// of the format argument that selects singular or plural
94#define XP(sing, plur, n) \
95 TranslatableString{ wxT(sing), {} }.Plural<(n)>( wxT(plur) )
96
97// Like XP but with an additional context argument, as for XC
98#define XPC(sing, plur, n, c) \
99 TranslatableString{ wxT(sing), {} }.Context(c).Plural<(n)>( wxT(plur) )
100
101class STRINGS_API Internat
102{
103public:
106 static void Init();
107
112 static wxChar GetDecimalSeparator();
113 static void SetCeeNumberFormat();
114
120 static bool CompatibleToDouble(const wxString& stringToConvert, double* result);
121
122 // Function version of above.
123 static double CompatibleToDouble(const wxString& stringToConvert);
124
127 static wxString ToString(double numberToConvert,
128 int digitsAfterDecimalPoint = -1);
129
132 static wxString ToDisplayString(double numberToConvert,
133 int digitsAfterDecimalPoint = -1);
134
137 static TranslatableString FormatSize(wxLongLong size);
138 static TranslatableString FormatSize(double size);
139
145 static bool SanitiseFilename(wxString &name, const wxString &sub);
146
147 static const wxArrayString &GetExcludedCharacters()
148 { return exclude; }
149
150private:
151 static wxChar mDecimalSeparator;
152
153 static wxArrayString exclude;
154};
155
156// Convert C strings to wxString
157#define UTF8CTOWX(X) wxString((X), wxConvUTF8)
158#define LAT1CTOWX(X) wxString((X), wxConvISO8859_1)
159
160// Whether disambiguationg contexts are supported
161// If not, then the program builds and runs, but strings in the catalog with
162// contexts will fail to translate
163#define HAS_I18N_CONTEXTS wxCHECK_VERSION(3, 1, 1)
164
165#endif
const TranslatableString name
Definition: Distortion.cpp:76
STRINGS_API const wxString & GetCustomTranslation(const wxString &str1)
Definition: Internat.cpp:46
STRINGS_API const wxString & GetCustomSubstitution(const wxString &str1)
Definition: Internat.cpp:39
Internationalisation support.
Definition: Internat.h:102
static wxChar mDecimalSeparator
Definition: Internat.h:151
static const wxArrayString & GetExcludedCharacters()
Definition: Internat.h:147
static wxArrayString exclude
Definition: Internat.h:153
Holds a msgid for the translation catalog; may also bind format arguments.
Extend wxArrayString with move operations and construction and insertion fromstd::initializer_list.
auto ToString(const std::optional< TimeSignature > &ts)