My favorites | Sign in
Project Home Downloads Source
Checkout   Browse   Changes    
 
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
topic "Internationalization and translation files";
[2 $$0,0#00000000000000000000000000000000:Default]
[l288;i704;a17;O9;~~~.992;2 $$1,0#10431211400427159095818037425705:param]
[a83;*R6 $$2,5#31310162474203024125188417583966:caption]
[b83;*2 $$3,5#07864147445237544204411237157677:title]
[b167;a42;C2 $$4,6#40027414424643823182269349404212:item]
[b42;a42;2 $$5,5#45413000475342174754091244180557:text]
[l288;a17;2 $$6,6#27521748481378242620020725143825:desc]
[l321;t246;C@5;1 $$7,7#20902679421464641399138805415013:code]
[b2503;2 $$8,0#65142375456100023862071332075487:separator]
[*@(0.0.255)2 $$9,0#83433469410354161042741608181528:base]
[t4167;C2 $$10,0#37138531426314131251341829483380:class]
[l288;a17;*1 $$11,11#70004532496200323422659154056402:requirement]
[i417;b42;a42;O9;~~~.416;2 $$12,12#10566046415157235020018451313112:tparam]
[b167;C2 $$13,13#92430459443460461911108080531343:item1]
[i288;a42;O9;C2 $$14,14#77422149456609303542238260500223:item2]
[*@2$(0.128.128)2 $$15,15#34511555403152284025741354420178:NewsDate]
[l321;*C$7;2 $$16,16#03451589433145915344929335295360:result]
[l321;b83;a83;*C$7;2 $$17,17#07531550463529505371228428965313:result`-line]
[l160;t4167;*C+117 $$18,5#88603949442205825958800053222425:package`-title]
[@(128.0.255)2 $$19,0#65874547464505293575048467215454:QTF Chr]
[{_}%EN-US
[s2; Internationalization and translation files&]
[s0; To internationalize your application, you need to provide versions
of string literals in all required languages. In U`+`+, you can
do this using translation files.&]
[s0; &]
[s0; To mark string literals for translation in sources, you have
to tag them with t`_ macro, like&]
[s0; &]
[s7; printf(t`_(`"Hello world!`"));&]
[s0; &]
[s0; This macro is expanded to function that provides translation
of English (more specifically en`-US) text to default language
set by SetLanguage function. String literal here is considered
to be the key for translation lookup. U`+`+ supports three forms
of keys here:&]
[s0; &]
[s0;i150;O0; plain keys are just en`-US texts. Example: t`_(`"Hello
world!`")&]
[s0;i150;O0; context keys consist of context and en`-US text separated
by `\v, where both are parts of key. Example: t`_(`"align`\vTop`").
This is useful in cases when context is needed to provide translation.&]
[s0;i150;O0; id keys consist of id and en`-US text separated by `\a,
but only id is used as key in translation lookup. Example: t`_(`"CtrlCoreReport`\a
Report`"). &]
[s0; &]
[s0; Important: t`_ tag can be used with string literals only.&]
[s0; &]
[s0; t`_ macro expands to function call that provides translation
of given literal. Where this is not acceptable (like in arrays
of literals), tt`_ tag can be used `- it is expanded to literal
alone and that can be later converted using GetLngString macro.&]
[s0; &]
[s0; Translations are stored in .t files of regular packages. Format
of this file is rather simple `- it is set of keys followed by
translation of keys to required languages. Key is introduced
by T`_, translation, translations are introduced by their language
codes, e.g.&]
[s0; &]
[s0; T`_(`"Sideways`")&]
[s0; csCZ(`"Na šířku`")&]
[s0; &]
[s0; Language codes for other languages may be found in Core, within
the lcid.txt file (found in the Languages section).&]
[s0; &]
[s0; TheIDE provides means for manipulating .t files `- in Workspace
menu there is `"Synchronize translation files`" operation. This
operation scans all source files of current project and builds
map of t`_ tagged string literals and then combines this information
with any valid .t files it finds. This operation also allows
adding new languages to .t files.&]
[s0; &]
[s0; t. files are always in UTF8 encoding. To change the encoding
for your file, you can right`-click on the file in TheIDE, and
select `'Convert to encoding...`'. Note that if you use Windows
Notepad to save the file as UTF`-8, you may need to strip out
the BOM that Windows may have included, or you may experience
compiling errors.&]
[s0; &]
[s0; TheIDE also maintains translation repository `- it stores ALL
translations that it meets into this file. Each time .t file
is synchronized, TheIDE tries to supply all missing translations
from repository and also adds all translation existing in .t
file back to repository. This is e.g. great when some source
is moved to another package.&]
[s0; &]
[s0; U`+`+ also supports run`-time translations (as opposite to compile`-time
.t files). You can use `-`-export`-tr in any U`+`+ application
to force creation of runtime translation file (with .tr extension).
Parameters of this flag is 4 letter language code and single
letter character set encoding according this table:&]
[s0; &]
[s0; &]
[ {{1840:8160<330;>1757;f4;h1; [s19;= [C `_]]
:: [s0; utf`-8]
:: [s19;= [C 0]]
:: [s0; windows`-1250]
:: [s19;= [C 1]]
:: [s0; windows`-1251]
:: [s19;= [C 2]]
:: [s0; windows`-1252]
:: [s19;= [C 3]]
:: [s0; windows`-1253]
:: [s19;= [C 4]]
:: [s0; windows`-1254]
:: [s19;= [C 5]]
:: [s0; windows`-1255]
:: [s19;= [C 6]]
:: [s0; windows`-1256]
:: [s19;= [C 7]]
:: [s0; windows`-1257]
:: [s19;= [C A]]
:: [s0; iso`-8859`-1]
:: [s19;= [C B]]
:: [s0; iso`-8859`-2]
:: [s19;= [C C]]
:: [s0; iso`-8859`-3]
:: [s19;= [C D]]
:: [s0; iso`-8859`-4]
:: [s19;= [C E]]
:: [s0; iso`-8859`-5]
:: [s19;= [C F]]
:: [s0; iso`-8859`-6]
:: [s19;= [C G]]
:: [s0; iso`-8859`-7]
:: [s19;= [C H]]
:: [s0; iso`-8859`-8]
:: [s19;= [C I]]
:: [s0; iso`-8859`-9]
:: [s19;= [C J]]
:: [s0; iso`-8859`-10]}}&]
[s0; &]
[s0; example:&]
[s0; &]
[s7; myapp `-`-export`-tr dede2&]
[s0; &]
[s0; will create dede2.tr file (in exe directory on Win32 and user`'s
home folder on Posix) ready for translation to deDE in windows`-1252.
If translations are already present, they are supplied, otherwise
.tr file contains english strings in place of translations.&]
[s0; &]
[s0; It is also possible to output secondary already translated language
to .tr file as comments (e.g. in case that translator cannot
understand english, but can understand some other language):&]
[s0; &]
[s0; &]
[s7; myapp `-`-export`-tr dede2 cscz&]
[s0; &]
[s0; Each U`+`+ application performs search for .tr files at startup
and uses them to extend internal translation tables.&]
[s0; &]
[s0; .tr files can be also imported to .t files using TheIDE`'s `"Import
runtime translation`" function of Workspace menu. Note that this
function does not add new languages to .t files `- just adds
translations to languages added manually.&]
[s0; &]
[s0; When `-`-export`-tr is used without parameter, it exports all
compile`-time languages. This is useful for maintainance purposes.&]
[s0; &]
[s0; You will need to include the following in one of your compiled
files (not a header):&]
[s0; &]
[s7; #define TFILE <YourProject/YourTranslations.t>&]
[s7; #include <Core/t.h>&]
[s0; &]
[s0; where `'YourProject/YourTranslations.t`' would be a path to
your translations file.&]
[s0; &]
[s0; To set your application`'s language to the user`'s default language,
add the following somewhere early in your application`'s execution:&]
[s0; &]
[s7; SetLanguage( GetSystemLNG() );&]
[s0; &]
[s0; ]

Change log

r4187 by micio on Nov 22, 2011   Diff
Core/srcdoc.tpp : updated help page for
Internationalization
Go to: 
Project members, sign in to write a code review

Older revisions

r4141 by cxl on Nov 7, 2011   Diff
Core: Support for secondary .tr
language
r1325 by cxl on Jun 21, 2009   Diff
Core: Doc fix
r281 by mdelfede on Jun 7, 2008   Diff
changed svn layout
All revisions of this file

File info

Size: 7132 bytes, 175 lines

File properties

svn:eol-style
native
Powered by Google Project Hosting