-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcombinetranslationfiles.ui
391 lines (391 loc) · 22.9 KB
/
combinetranslationfiles.ui
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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CombineTranslationFiles</class>
<widget class="QMainWindow" name="CombineTranslationFiles">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1477</width>
<height>718</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="windowTitle">
<string>Merge Qt .ts files</string>
</property>
<property name="styleSheet">
<string notr="true">#titleWidget{background-color:white;}</string>
</property>
<widget class="QWidget" name="centralWidget">
<layout class="QVBoxLayout" name="verticalLayout_6">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QWidget" name="titleWidget" native="true">
<property name="styleSheet">
<string notr="true"/>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QWidget" name="titleWidgetInner" native="true">
<property name="minimumSize">
<size>
<width>700</width>
<height>0</height>
</size>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="label_2">
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string><html><head/><body><p><span style=" font-weight:600;">Combine multiple Qt .ts files into one<br/></span><a href="https://github.com/savolai/Merge-Qt-TS-files/"><span style=" text-decoration: underline; color:#0000ff;">https://github.com/savolai/Merge-Qt-TS-files/</span></a></p></body></html></string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="helpPushButton">
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">padding:0.5em;</string>
</property>
<property name="text">
<string>Show Help</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
<zorder></zorder>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QWidget" name="widget" native="true">
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QWidget" name="widget_2" native="true">
<property name="minimumSize">
<size>
<width>700</width>
<height>0</height>
</size>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="TSDropEdit" name="sourceFile">
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">padding:0.5em;</string>
</property>
<property name="placeholderText">
<string>Source file for translations</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="sourceFilePushButton">
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">padding:0.5em;</string>
</property>
<property name="text">
<string>Browse source...</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="sourceFilePushButton_2">
<property name="font">
<font>
<pointsize>10</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true">padding:0.5em;</string>
</property>
<property name="text">
<string>Read in selected file</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="TSDropEdit" name="targetFile">
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">padding:0.5em;</string>
</property>
<property name="placeholderText">
<string>File to save translations in</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="targetFilePushButton">
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">padding:0.5em;</string>
</property>
<property name="text">
<string>Browse target...</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Language of last read file:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="language">
<property name="text">
<string>[none]</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QTextBrowser" name="textBrowser">
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="styleSheet">
<string notr="true">padding:0.5em; font-size:10pt;</string>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Apply|QDialogButtonBox::Reset</set>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QDockWidget" name="dockWidget">
<property name="minimumSize">
<size>
<width>400</width>
<height>87</height>
</size>
</property>
<property name="features">
<set>QDockWidget::DockWidgetClosable|QDockWidget::DockWidgetFloatable</set>
</property>
<property name="allowedAreas">
<set>Qt::RightDockWidgetArea</set>
</property>
<property name="windowTitle">
<string>Help</string>
</property>
<attribute name="dockWidgetArea">
<number>2</number>
</attribute>
<widget class="QWidget" name="dockWidgetContents">
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QTextBrowser" name="textBrowser_2">
<property name="font">
<font>
<pointsize>8</pointsize>
</font>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="html">
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
p, li { white-space: pre-wrap; }
</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8pt; font-weight:400; font-style:normal;" bgcolor="#ffffff">
<p style=" margin-top:10px; margin-bottom:0px; margin-left:10px; margin-right:10px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Segoe UI,Arial,Helvetica,MS Shell Dlg 2'; font-size:10pt; font-weight:600;">Usage: </span></p>
<ol style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; -qt-list-indent: 1;"><li style=" font-family:'Segoe UI,Arial,Helvetica,MS Shell Dlg 2'; font-size:10pt; font-weight:600;" style=" margin-top:12px; margin-bottom:0px; margin-left:10px; margin-right:10px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:400;">Open each source file by pressing &quot;Browse source...&quot;. After doing that, click &quot;Read in selected file&quot;. You will get a count of translations loaded into memory.</span></li>
<li style=" font-family:'Segoe UI,Arial,Helvetica,MS Shell Dlg 2'; font-size:10pt;" style=" margin-top:12px; margin-bottom:0px; margin-left:10px; margin-right:10px; -qt-block-indent:0; text-indent:0px;">Repeat step 1 for each file you want to combine</li>
<li style=" font-family:'Segoe UI,Arial,Helvetica,MS Shell Dlg 2'; font-size:10pt;" style=" margin-top:12px; margin-bottom:0px; margin-left:10px; margin-right:10px; -qt-block-indent:0; text-indent:0px;">After reading into memory all your translation data, select target file by pressing &quot;Browse target...&quot;. After selecting filename to save to, press &quot;Write translations to file&quot;. </li></ol>
<p style=" margin-top:12px; margin-bottom:0px; margin-left:10px; margin-right:10px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Segoe UI,Arial,Helvetica,MS Shell Dlg 2'; font-size:10pt; font-weight:600;">This app is designed to preserve as much as possible of the information in the translation files. </span></p>
<p style=" margin-top:12px; margin-bottom:0px; margin-left:10px; margin-right:10px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Segoe UI,Arial,Helvetica,MS Shell Dlg 2'; font-size:10pt;">When combining multiple translation files, this makes sure translations with empty content never override translations with existing content.</span></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:10px; margin-right:10px; -qt-block-indent:0; text-indent:0px; font-family:'Segoe UI,Arial,Helvetica,MS Shell Dlg 2'; font-size:10pt;"><br /></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:10px; margin-right:10px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Segoe UI,Arial,Helvetica,MS Shell Dlg 2'; font-size:10pt;">If multiple of your source files contain conflicting, nonempty, translations for the same translation units (i.e classname+source text content), make sure to load the file that has the translations you want, last.</span></p>
<p style=" margin-top:12px; margin-bottom:0px; margin-left:10px; margin-right:10px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Segoe UI,Arial,Helvetica,MS Shell Dlg 2'; font-size:10pt;">Caveat: This tool does NOT currently include </span><span style=" font-family:'Segoe UI,Arial,Helvetica,MS Shell Dlg 2'; font-size:10pt; font-weight:600;">multiple</span><span style=" font-family:'Segoe UI,Arial,Helvetica,MS Shell Dlg 2'; font-size:10pt;"> &lt;location&gt; elements if many exist in source translation units, only one of them is included for each translation. Mostly this never makes any difference, since a single run of lupdate project1.pro project2.pro -ts projects.ts (where projects.ts is the output file of this program) will put all the additional locations back again. </span></p>
<p style=" margin-top:12px; margin-bottom:0px; margin-left:10px; margin-right:10px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Segoe UI,Arial,Helvetica,MS Shell Dlg 2'; font-size:10pt; font-weight:600;">Background</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:10px; margin-right:10px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Segoe UI,Arial,Helvetica,MS Shell Dlg 2'; font-size:10pt;">This is useful when you have multiple applications</span></p>
<ol style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; -qt-list-indent: 1;"><li style=" font-family:'Segoe UI,Arial,Helvetica,MS Shell Dlg 2'; font-size:10pt;" style=" margin-top:12px; margin-bottom:0px; margin-left:10px; margin-right:10px; -qt-block-indent:0; text-indent:0px;">that have language files of their own</li>
<li style=" font-family:'Segoe UI,Arial,Helvetica,MS Shell Dlg 2'; font-size:10pt;" style=" margin-top:12px; margin-bottom:0px; margin-left:10px; margin-right:10px; -qt-block-indent:0; text-indent:0px;">that statically link to common libraries that also have translations</li></ol>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:10px; margin-right:10px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Segoe UI,Arial,Helvetica,MS Shell Dlg 2'; font-size:10pt;"> </span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:10px; margin-right:10px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Segoe UI,Arial,Helvetica,MS Shell Dlg 2'; font-size:10pt; font-weight:600;">In this situation, overlaps in translation files can cause strings not getting translated in the UI.</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:10px; margin-right:10px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Segoe UI,Arial,Helvetica,MS Shell Dlg 2'; font-size:10pt;">Also, Qt docs don't exactly warn about this situation, and also it tends to creep up on you; I found myself in a situation with hundreds of translation spread across multiple translation files that should have been one. So I wrote this to fix it.</span></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:10px; margin-right:10px; -qt-block-indent:0; text-indent:0px; font-family:'Segoe UI,Arial,Helvetica,MS Shell Dlg 2'; font-size:10pt;"><br /></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:10px; margin-right:10px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Segoe UI,Arial,Helvetica,MS Shell Dlg 2'; font-size:10pt; font-weight:600;">The solution is to produce a common translation file for all the apps. </span><span style=" font-family:'Segoe UI,Arial,Helvetica,MS Shell Dlg 2'; font-size:10pt;">First run your ts files through this app, combining translations. Then run lupdate like below - this updates the location tags of the translations to point to the right place(s).</span></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:10px; margin-right:10px; -qt-block-indent:0; text-indent:0px; font-family:'Segoe UI,Arial,Helvetica,MS Shell Dlg 2'; font-size:10pt;"><br /></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:10px; margin-right:10px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Segoe UI,Arial,Helvetica,MS Shell Dlg 2'; font-size:10pt;">After that, you can normally run lrelease on your ts file to produce .qm and load it from all your apps.</span></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:10px; margin-right:10px; -qt-block-indent:0; text-indent:0px; font-family:'Segoe UI,Arial,Helvetica,MS Shell Dlg 2'; font-size:10pt;"><br /></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:10px; margin-right:10px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Segoe UI,Arial,Helvetica,MS Shell Dlg 2'; font-size:10pt;">Thanks @David Faure for pointing me in the right direction.</span></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:10px; margin-right:10px; -qt-block-indent:0; text-indent:0px; font-family:'Segoe UI,Arial,Helvetica,MS Shell Dlg 2'; font-size:10pt;"><br /></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:10px; margin-right:10px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Segoe UI,Arial,Helvetica,MS Shell Dlg 2'; font-size:10pt;">Another option might be to load first the app specific language file and then on top of that, the translations for the common components. This occured to me too late. \o/ however, having all project translations in a single file tends to be a cleaner solution overall, as you will always know what has already been translated.</span></p>
<p style=" margin-top:12px; margin-bottom:12px; margin-left:10px; margin-right:10px; -qt-block-indent:0; text-indent:0px;"><a name="js-repo-pjax-container"></a><span style=" font-family:'Segoe UI,Arial,Helvetica,MS Shell Dlg 2'; font-size:10pt;">O</span><span style=" font-family:'Segoe UI,Arial,Helvetica,MS Shell Dlg 2'; font-size:10pt;">ther options that might help:</span></p>
<ol style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; -qt-list-indent: 1;"><li style=" font-family:'Segoe UI,Arial,Helvetica,MS Shell Dlg 2'; font-size:10pt;" style=" margin-top:12px; margin-bottom:0px; margin-left:10px; margin-right:10px; -qt-block-indent:0; text-indent:0px;">When loading translation files into your app, first load the app specific language file and then on top of that, the translations for the common components. This occured to me too late. \o/ however, having all project translations in a single file tends to be a cleaner solution overall, as you will always know what has already been translated.</li>
<li style=" font-family:'Segoe UI,Arial,Helvetica,MS Shell Dlg 2'; font-size:10pt;" style=" margin-top:0px; margin-bottom:12px; margin-left:10px; margin-right:10px; -qt-block-indent:0; text-indent:0px;">Using an XML merging tool such as those mentioned <a href="http://stackoverflow.com/questions/80609/merge-xml-documents"><span style=" text-decoration: underline; color:#0000ff;">in this StackOverflow post</span></a> might also work, but I enjoyed making this and emh, now we have a GUI :)</li></ol></body></html></string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>
<customwidget>
<class>TSDropEdit</class>
<extends>QLineEdit</extends>
<header>tsdropedit.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>