Skip to content

Commit c5e70fd

Browse files
authored
Merge pull request #54 from WhereGroup/tooling/add-script-to-update-translation
Tooling: add script to update translation
2 parents b061081 + 75e5b38 commit c5e70fd

File tree

9 files changed

+1171
-432
lines changed

9 files changed

+1171
-432
lines changed

docs/development/translation.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,25 @@ sudo apt install qttools5-dev-tools
1010

1111
## Workflow
1212

13+
1. Generate the `plugin_translation.pro` file:
14+
15+
```bash
16+
python scripts/generate_translation_profile.py
17+
```
18+
1319
1. Update `.ts` files:
1420

1521
```bash
1622
pylupdate5 -verbose profile_manager/resources/i18n/plugin_translation.pro
1723
```
1824

19-
2. Translate your text using QLinguist or directly into `.ts` files.
20-
3. Compile it:
25+
1. Translate your text using QLinguist or directly into `.ts` files. Launching it through command-line is possible:
26+
27+
```bash
28+
linguist profile_manager/resources/i18n/*.ts
29+
```
30+
31+
1. Compile it:
2132

2233
```bash
2334
lrelease profile_manager/resources/i18n/*.ts

profile_manager/profile_manager.py

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from qgis.PyQt.QtGui import QIcon
1010
from qgis.PyQt.QtWidgets import QAction, QWidget
1111

12+
from profile_manager.__about__ import __title__, __title_clean__
1213
from profile_manager.handlers.bookmarks import import_bookmarks
1314
from profile_manager.handlers.customization import import_customizations
1415
from profile_manager.handlers.data_sources import (
@@ -36,7 +37,7 @@
3637
from profile_manager.profiles.utils import get_profile_qgis_ini_path, qgis_profiles_path
3738
from profile_manager.utils import wait_cursor
3839

39-
LOGGER = logging.getLogger("profile_manager")
40+
LOGGER = logging.getLogger(__title_clean__)
4041
logging.basicConfig(
4142
format="%(asctime)s,%(msecs)d %(name)s %(levelname)s %(message)s",
4243
datefmt="%H:%M:%S",
@@ -69,7 +70,7 @@ def __init__(self, iface):
6970

7071
# Declare instance attributes
7172
self.action: Optional[QAction] = None
72-
self.menu = self.tr("&Profile Manager")
73+
self.menu = __title__
7374

7475
# Check if plugin was started the first time in current QGIS session
7576
# Must be set in initGui() to survive plugin reloads
@@ -96,7 +97,7 @@ def initGui(self):
9697
"""Create the menu entries and toolbar icons inside the QGIS GUI."""
9798

9899
icon = QIcon(str(self.__plugin_dir / "icon.png"))
99-
action = QAction(icon, self.tr("Profile Manager"), self.iface.mainWindow())
100+
action = QAction(icon, __title__, self.iface.mainWindow())
100101
action.triggered.connect(self.run)
101102
action.setEnabled(True)
102103
self.iface.addToolBarIcon(action)
@@ -165,7 +166,7 @@ def make_backup(self, profile_name: str) -> Optional[str]:
165166
source_path = qgis_profiles_path() / profile_name
166167
QgsMessageLog.logMessage(
167168
f"Backing up profile {profile_name!r} to {target_path!r}",
168-
"Profile Manager",
169+
__title__,
169170
level=Qgis.MessageLevel.Info,
170171
)
171172
try:
@@ -234,7 +235,7 @@ def import_things(
234235
self.tr("Importing {} data sources...").format(
235236
sum([len(v) for v in data_sources.values()])
236237
),
237-
"Profile Manager",
238+
__title__,
238239
level=Qgis.MessageLevel.Info,
239240
)
240241
try:
@@ -252,7 +253,7 @@ def import_things(
252253
if plugins:
253254
QgsMessageLog.logMessage(
254255
self.tr("Importing {} plugins...").format(len(plugins)),
255-
"Profile Manager",
256+
__title__,
256257
level=Qgis.MessageLevel.Info,
257258
)
258259
try:
@@ -271,7 +272,7 @@ def import_things(
271272
if do_import_bookmarks:
272273
QgsMessageLog.logMessage(
273274
self.tr("Importing bookmarks..."),
274-
"Profile Manager",
275+
__title__,
275276
level=Qgis.MessageLevel.Info,
276277
)
277278
try:
@@ -287,7 +288,7 @@ def import_things(
287288
if do_import_favourites:
288289
QgsMessageLog.logMessage(
289290
self.tr("Importing favourites..."),
290-
"Profile Manager",
291+
__title__,
291292
level=Qgis.MessageLevel.Info,
292293
)
293294
try:
@@ -300,7 +301,7 @@ def import_things(
300301
if do_import_models:
301302
QgsMessageLog.logMessage(
302303
self.tr("Importing models..."),
303-
"Profile Manager",
304+
__title__,
304305
level=Qgis.MessageLevel.Info,
305306
)
306307
try:
@@ -313,7 +314,7 @@ def import_things(
313314
if do_import_scripts:
314315
QgsMessageLog.logMessage(
315316
self.tr("Importing scripts..."),
316-
"Profile Manager",
317+
__title__,
317318
level=Qgis.MessageLevel.Info,
318319
)
319320
try:
@@ -326,7 +327,7 @@ def import_things(
326327
if do_import_styles:
327328
QgsMessageLog.logMessage(
328329
self.tr("Importing styles..."),
329-
"Profile Manager",
330+
__title__,
330331
level=Qgis.MessageLevel.Info,
331332
)
332333
try:
@@ -339,7 +340,7 @@ def import_things(
339340
if do_import_expressions:
340341
QgsMessageLog.logMessage(
341342
self.tr("Importing expressions..."),
342-
"Profile Manager",
343+
__title__,
343344
level=Qgis.MessageLevel.Info,
344345
)
345346
try:
@@ -352,7 +353,7 @@ def import_things(
352353
if do_import_customizations:
353354
QgsMessageLog.logMessage(
354355
self.tr("Importing customizations..."),
355-
"Profile Manager",
356+
__title__,
356357
level=Qgis.MessageLevel.Info,
357358
)
358359
try:
@@ -377,7 +378,7 @@ def remove_things(
377378
self.tr("Removing {} data sources...").format(
378379
sum([len(v) for v in data_sources.values()])
379380
),
380-
"Profile Manager",
381+
__title__,
381382
level=Qgis.MessageLevel.Info,
382383
)
383384
try:
@@ -395,7 +396,7 @@ def remove_things(
395396
if plugins:
396397
QgsMessageLog.logMessage(
397398
self.tr("Removing {} plugins...").format(len(plugins)),
398-
"Profile Manager",
399+
__title__,
399400
level=Qgis.MessageLevel.Info,
400401
)
401402
try:

profile_manager/profile_manager_dialog_base.ui

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
<property name="windowTitle">
1414
<string>Profile Manager</string>
1515
</property>
16+
<property name="locale">
17+
<locale language="English" country="UnitedStates"/>
18+
</property>
1619
<property name="sizeGripEnabled">
1720
<bool>false</bool>
1821
</property>

0 commit comments

Comments
 (0)