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 // Eventually pulls in <windows.h> which indirectly defines DebugBreak(). Can't
60 // include <windows.h> directly since it then causes "MemoryX.h" to spew errors.
61 #include <wx/app.h>
62 #define _(s) ((wxTranslations::Get() || (DebugBreak(), true)), \
63 GetCustomTranslation((s)))
64
65 #else
66
67 #include <signal.h>
68 // Raise a signal because it's even too early to use wxASSERT for this.
69 #define _(s) ((wxTranslations::Get() || raise(SIGTRAP)), \
70 GetCustomTranslation((s)))
71
72 #endif
73
74#else
75 #define _(s) GetCustomTranslation((s))
76#endif
77
78#ifdef XP
79 #undef XP
80#endif
81
82
83// The two string arguments will go to the .pot file, as
84// msgid sing
85// msgid_plural plural
86//
87// (You must use plain string literals. Do not use _() or wxT() or L prefix,
88// which (intentionally) will fail to compile. The macro inserts wxT).
89//
90// Note too: The i18n-hint comment must be on the line preceding the first
91// string. That might be inside the parentheses of the macro call.
92//
93// The macro call is then followed by a sequence of format arguments in
94// parentheses. The third argument of the macro call is the zero-based index
95// of the format argument that selects singular or plural
96#define XP(sing, plur, n) \
97 TranslatableString{ wxT(sing), {} }.Plural<(n)>( wxT(plur) )
98
99// Like XP but with an additional context argument, as for XC
100#define XPC(sing, plur, n, c) \
101 TranslatableString{ wxT(sing), {} }.Context(c).Plural<(n)>( wxT(plur) )
102
103class STRINGS_API Internat
104{
105public:
108 static void Init();
109
114 static wxChar GetDecimalSeparator();
115 static void SetCeeNumberFormat();
116
122 static bool CompatibleToDouble(const wxString& stringToConvert, double* result);
123
124 // Function version of above.
125 static double CompatibleToDouble(const wxString& stringToConvert);
126
129 static wxString ToString(double numberToConvert,
130 int digitsAfterDecimalPoint = -1);
131
134 static wxString ToDisplayString(double numberToConvert,
135 int digitsAfterDecimalPoint = -1);
136
139 static TranslatableString FormatSize(wxLongLong size);
140 static TranslatableString FormatSize(double size);
141
147 static bool SanitiseFilename(wxString &name, const wxString &sub);
148
149 static const wxArrayString &GetExcludedCharacters()
150 { return exclude; }
151
152private:
153 static wxChar mDecimalSeparator;
154
155 static wxArrayString exclude;
156};
157
158// Convert C strings to wxString
159#define UTF8CTOWX(X) wxString((X), wxConvUTF8)
160#define LAT1CTOWX(X) wxString((X), wxConvISO8859_1)
161
162// Whether disambiguationg contexts are supported
163// If not, then the program builds and runs, but strings in the catalog with
164// contexts will fail to translate
165#define HAS_I18N_CONTEXTS wxCHECK_VERSION(3, 1, 1)
166
167#endif
const TranslatableString name
Definition: Distortion.cpp:82
STRINGS_API const wxString & GetCustomTranslation(const wxString &str1)
Definition: Internat.cpp:71
STRINGS_API const wxString & GetCustomSubstitution(const wxString &str1)
Definition: Internat.cpp:63
Internationalisation support.
Definition: Internat.h:104
static wxChar mDecimalSeparator
Definition: Internat.h:153
static const wxArrayString & GetExcludedCharacters()
Definition: Internat.h:149
static wxArrayString exclude
Definition: Internat.h:155
Holds a msgid for the translation catalog; may also bind format arguments.
Extend wxArrayString with move operations and construction and insertion fromstd::initializer_list.
std::string ToString(const wxString &str)
Definition: Journal.cpp:75