Skip to content

Commit

Permalink
Merge pull request #177 from MIERUNE/feat/multilanguage
Browse files Browse the repository at this point in the history
Feat/multilanguage
  • Loading branch information
nbayashi authored Sep 13, 2024
2 parents 1309653 + cfa0e57 commit c3ebd25
Show file tree
Hide file tree
Showing 10 changed files with 367 additions and 26 deletions.
142 changes: 142 additions & 0 deletions i18n/QGIS2PlugX_en.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS><TS version="2.0">
<context>
<name>Dialog</name>
<message>
<location filename="../ui/main_dialog.ui" line="14"/>
<source>Dialog</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/main_dialog.ui" line="20"/>
<source>Layers to export</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/main_dialog.ui" line="42"/>
<source>Map parameters</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/main_dialog.ui" line="51"/>
<source>Output Scale</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/main_dialog.ui" line="73"/>
<source>Select the output folder and execute</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/main_dialog.ui" line="80"/>
<source>Cancel</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/main_dialog.ui" line="87"/>
<source>Help</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/progress_dialog.ui" line="20"/>
<source>Processing...</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/progress_dialog.ui" line="44"/>
<source>%v/%m</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/progress_dialog.ui" line="51"/>
<source>Text</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/progress_dialog.ui" line="69"/>
<source>Abort</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>MainDialog</name>
<message>
<location filename="../ui/main_dialog.py" line="194"/>
<source>Error</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/main_dialog.py" line="168"/>
<source>Process completed</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/main_dialog.py" line="175"/>
<source>The following layers contains unsupported symbols</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/main_dialog.py" line="176"/>
<source>and have been converted to simple symbols.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/main_dialog.py" line="181"/>
<source>Failed to export the following layers.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/main_dialog.py" line="183"/>
<source>Completed</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/main_dialog.py" line="194"/>
<source>Failed to delete the temporary folder. Please delete it manually.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/main_dialog.py" line="100"/>
<source>An error occured.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/main_dialog.py" line="170"/>
<source>Output folder</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ProgressDialog</name>
<message>
<location filename="../ui/progress_dialog.py" line="28"/>
<source>Initializing process...</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/progress_dialog.py" line="32"/>
<source>Cancel</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/progress_dialog.py" line="41"/>
<source>Check</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/progress_dialog.py" line="41"/>
<source>Are you sure to abort the process?</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/progress_dialog.py" line="51"/>
<source>Aborting...</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/progress_dialog.py" line="68"/>
<source>Processing: </source>
<translation type="unfinished"></translation>
</message>
</context>
</TS>
Binary file added i18n/QGIS2PlugX_ja.qm
Binary file not shown.
143 changes: 143 additions & 0 deletions i18n/QGIS2PlugX_ja.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="ja">
<context>
<name>Dialog</name>
<message>
<location filename="../ui/main_dialog.ui" line="14"/>
<source>Dialog</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/main_dialog.ui" line="20"/>
<source>Layers to export</source>
<translation type="unfinished">レイヤー設定</translation>
</message>
<message>
<location filename="../ui/main_dialog.ui" line="42"/>
<source>Map parameters</source>
<translation type="unfinished">マップ設定</translation>
</message>
<message>
<location filename="../ui/main_dialog.ui" line="51"/>
<source>Output Scale</source>
<translation type="unfinished">出力縮尺</translation>
</message>
<message>
<location filename="../ui/main_dialog.ui" line="73"/>
<source>Select the output folder and execute</source>
<translation type="unfinished">出力フォルダーを選択して実行</translation>
</message>
<message>
<location filename="../ui/main_dialog.ui" line="80"/>
<source>Cancel</source>
<translation type="unfinished">キャンセル</translation>
</message>
<message>
<location filename="../ui/main_dialog.ui" line="87"/>
<source>Help</source>
<translation type="unfinished">ヘルプ</translation>
</message>
<message>
<location filename="../ui/progress_dialog.ui" line="20"/>
<source>Processing...</source>
<translation type="unfinished">処理中...</translation>
</message>
<message>
<location filename="../ui/progress_dialog.ui" line="44"/>
<source>%v/%m</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/progress_dialog.ui" line="51"/>
<source>Text</source>
<translation type="unfinished">テキスト</translation>
</message>
<message>
<location filename="../ui/progress_dialog.ui" line="69"/>
<source>Abort</source>
<translation type="unfinished">中断</translation>
</message>
</context>
<context>
<name>MainDialog</name>
<message>
<location filename="../ui/main_dialog.py" line="194"/>
<source>Error</source>
<translation type="unfinished">エラー</translation>
</message>
<message>
<location filename="../ui/main_dialog.py" line="168"/>
<source>Process completed</source>
<translation type="unfinished">処理が完了しました。</translation>
</message>
<message>
<location filename="../ui/main_dialog.py" line="175"/>
<source>The following layers contains unsupported symbols</source>
<translation type="unfinished">以下レイヤに対応不可なシンボロジがあるため、</translation>
</message>
<message>
<location filename="../ui/main_dialog.py" line="176"/>
<source>and have been converted to simple symbols.</source>
<translation type="unfinished">シンプルシンボルに変換しました。</translation>
</message>
<message>
<location filename="../ui/main_dialog.py" line="181"/>
<source>Failed to export the following layers.</source>
<translation type="unfinished">以下のレイヤーは出力できませんでした。</translation>
</message>
<message>
<location filename="../ui/main_dialog.py" line="183"/>
<source>Completed</source>
<translation type="unfinished">完了</translation>
</message>
<message>
<location filename="../ui/main_dialog.py" line="194"/>
<source>Failed to delete the temporary folder. Please delete it manually.</source>
<translation type="unfinished">一時フォルダの削除に失敗しました。手動で削除してください。</translation>
</message>
<message>
<location filename="../ui/main_dialog.py" line="100"/>
<source>An error occured.</source>
<translation type="unfinished">エラーが発生しました。</translation>
</message>
<message>
<location filename="../ui/main_dialog.py" line="170"/>
<source>Output folder</source>
<translation type="unfinished">出力先</translation>
</message>
</context>
<context>
<name>ProgressDialog</name>
<message>
<location filename="../ui/progress_dialog.py" line="28"/>
<source>Initializing process...</source>
<translation type="unfinished">処理開始中...</translation>
</message>
<message>
<location filename="../ui/progress_dialog.py" line="32"/>
<source>Cancel</source>
<translation type="unfinished">中断</translation>
</message>
<message>
<location filename="../ui/progress_dialog.py" line="41"/>
<source>Check</source>
<translation type="unfinished">確認</translation>
</message>
<message>
<location filename="../ui/progress_dialog.py" line="41"/>
<source>Are you sure to abort the process?</source>
<translation type="unfinished">処理を中断し、以降の処理をスキップしてよろしいですか?</translation>
</message>
<message>
<location filename="../ui/progress_dialog.py" line="51"/>
<source>Aborting...</source>
<translation type="unfinished">中断待機中...</translation>
</message>
<message>
<location filename="../ui/progress_dialog.py" line="68"/>
<source>Processing: </source>
<translation type="unfinished">処理中:</translation>
</message>
</context>
</TS>
7 changes: 7 additions & 0 deletions qgis2plugx.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
SOURCES += qgis2plugx.py \
ui/main_dialog.py \
ui/progress_dialog.py

FORMS += ./ui/main_dialog.ui ./ui/progress_dialog.ui

TRANSLATIONS = ./i18n/QGIS2PlugX_ja.ts ./i18n/QGIS2PlugX_en.ts
14 changes: 14 additions & 0 deletions qgis2plugx.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from PyQt5.QtGui import QIcon
from PyQt5.QtWidgets import QAction
from PyQt5.QtCore import QSettings, QTranslator, QCoreApplication
from qgis.gui import QgisInterface

from ui.main_dialog import MainDialog
Expand All @@ -25,6 +26,19 @@ def __init__(self, iface: QgisInterface):
self.main_dialog = None
self.about_dialog = None

locale = QSettings().value("locale/userLocale")[0:2]
locale_path = os.path.join(
self.plugin_dir, "i18n", "QGIS2PlugX_{}.qm".format(locale)
)

if os.path.exists(locale_path):
self.translator = QTranslator()
self.translator.load(locale_path)
QCoreApplication.installTranslator(self.translator)

def tr(self, message):
return QCoreApplication.translate("QGIS2PlugX", message)

def add_action(
self,
icon_path,
Expand Down
2 changes: 1 addition & 1 deletion translator/thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def run(self):
self.results.append(result)

# emit progress
self.postMessage.emit(f"処理中: {layer.name()}")
self.postMessage.emit("Processing: " + layer.name())
self.setAbortable.emit(True)
self.addProgress.emit(1)
except Exception as e:
Expand Down
Loading

0 comments on commit c3ebd25

Please sign in to comment.