Skip to content

Commit 2c51d68

Browse files
committed
Updated translations and fixed issue with zh_CN selection on MacOS
1 parent 8b9fb80 commit 2c51d68

File tree

6 files changed

+11324
-11028
lines changed

6 files changed

+11324
-11028
lines changed

GUI/Qt/Translations/itksnap_de.ts

Lines changed: 3766 additions & 3679 deletions
Large diffs are not rendered by default.

GUI/Qt/Translations/itksnap_es.ts

Lines changed: 3765 additions & 3678 deletions
Large diffs are not rendered by default.

GUI/Qt/Translations/itksnap_zh_CN.ts

Lines changed: 3749 additions & 3662 deletions
Large diffs are not rendered by default.

GUI/Qt/main.cxx

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1031,21 +1031,31 @@ main(int argc, char *argv[])
10311031
// Load the user preferences
10321032
gui->LoadUserPreferences();
10331033

1034-
// Print locale information
1034+
// Set the locale from the command line argument
10351035
if (argdata.gui_language.size())
10361036
{
10371037
QLocale::setDefault(QLocale(argdata.gui_language.c_str()));
10381038
qDebug() << "ITK-SNAP using locale:" << QLocale().name();
10391039
}
1040+
1041+
// Adjust the locale for discrepancy between zh_CN and zh-Hans_US codes that
1042+
// are used on MacOS
1043+
QLocale locale;
1044+
if(locale.language() == QLocale::Chinese && locale.script() == QLocale::SimplifiedChineseScript)
1045+
{
1046+
QLocale::setDefault(QLocale(QLocale::Chinese, QLocale::China));
1047+
locale = QLocale();
1048+
}
1049+
10401050
QTranslator translator;
1041-
if(translator.load(QLocale(), "itksnap", "_", ":/i18n"))
1051+
if(translator.load(locale, "itksnap", "_", ":/i18n"))
10421052
{
1043-
qDebug() << "Loaded translator for locale" << QLocale().name();
1053+
qDebug() << "Loaded translator for locale" << locale.name();
10441054
QCoreApplication::installTranslator(&translator);
10451055
}
10461056
else
10471057
{
1048-
qDebug() << "Failed to load translator for locale" << QLocale().name();
1058+
qDebug() << "Failed to load translator for locale" << locale.name();
10491059
}
10501060

10511061
QTranslator translator_sys;
@@ -1057,14 +1067,14 @@ main(int argc, char *argv[])
10571067
translator_sys_path = translator_sys_path.replace("Contents/translations","Contents/Resources/translations");
10581068
}
10591069
#endif
1060-
if (translator_sys.load(QLocale(), "qt", "_", translator_sys_path))
1070+
if (translator_sys.load(locale, "qt", "_", translator_sys_path))
10611071
{
1062-
qDebug() << "Loaded qtbase translator for locale" << QLocale().name();
1072+
qDebug() << "Loaded qtbase translator for locale" << locale.name();
10631073
QCoreApplication::installTranslator(&translator_sys);
10641074
}
10651075
else
10661076
{
1067-
qDebug() << "Failed to load qtbase translator for locale" << QLocale().name();
1077+
qDebug() << "Failed to load qtbase translator for locale" << locale.name();
10681078
qDebug() << " Search paths considered: " << translator_sys_path;
10691079
}
10701080

Utilities/MacOS/BundleResources/Info.plist

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
<array>
2323
<string>en</string>
2424
<string>es</string>
25-
<string>zh_CN</string>
25+
<string>zh-Hans</string>
26+
<string>de</string>
2627
</array>
2728
<key>CFBundleSignature</key>
2829
<string>itksnap</string>

Utilities/Translation/translate_itksnap.ipynb

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@
218218
" for con in self.all_con:\n",
219219
" all_strings = [x for xs in con['tran'] for x in xs['strings']]\n",
220220
" if len(all_strings):\n",
221-
" print(f\"Translating {con['context'].find('name').text}\")\n",
221+
" print(f\"Translating {con['context'].find('name').text} to {self.locale}\")\n",
222222
" gpt = translate(client, self.locale, all_strings)\n",
223223
" if gpt is None:\n",
224224
" continue\n",
@@ -255,8 +255,32 @@
255255
"name": "stdout",
256256
"output_type": "stream",
257257
"text": [
258+
"Translating GeneralLayerInspector\n",
259+
"Updating GeneralLayerInspector\n",
260+
"Translating LayerInspectorRowDelegate\n",
261+
"Updating LayerInspectorRowDelegate\n",
262+
"Translating MeshImportFileSelectionPage\n",
263+
"Updating MeshImportFileSelectionPage\n",
264+
"Translating ViewPanel3D\n",
265+
"Updating ViewPanel3D\n",
258266
"Wrote /Users/pauly/tk/itksnap/itksnap/GUI/Qt/Translations/itksnap_de.ts\n",
267+
"Translating GeneralLayerInspector\n",
268+
"Updating GeneralLayerInspector\n",
269+
"Translating LayerInspectorRowDelegate\n",
270+
"Updating LayerInspectorRowDelegate\n",
271+
"Translating MeshImportFileSelectionPage\n",
272+
"Updating MeshImportFileSelectionPage\n",
273+
"Translating ViewPanel3D\n",
274+
"Updating ViewPanel3D\n",
259275
"Wrote /Users/pauly/tk/itksnap/itksnap/GUI/Qt/Translations/itksnap_es.ts\n",
276+
"Translating GeneralLayerInspector\n",
277+
"Updating GeneralLayerInspector\n",
278+
"Translating LayerInspectorRowDelegate\n",
279+
"Updating LayerInspectorRowDelegate\n",
280+
"Translating MeshImportFileSelectionPage\n",
281+
"Updating MeshImportFileSelectionPage\n",
282+
"Translating ViewPanel3D\n",
283+
"Updating ViewPanel3D\n",
260284
"Wrote /Users/pauly/tk/itksnap/itksnap/GUI/Qt/Translations/itksnap_zh_CN.ts\n"
261285
]
262286
}

0 commit comments

Comments
 (0)