Skip to content

Commit

Permalink
Merge pull request #21 from MIERUNE/feat/multi-language
Browse files Browse the repository at this point in the history
メッセージの多言語化
  • Loading branch information
Raymond Lay authored May 27, 2024
2 parents f50df57 + 95fc7c1 commit 86ca2e1
Show file tree
Hide file tree
Showing 7 changed files with 159 additions and 2 deletions.
Binary file added i18n/jaxaEarthApi_en.qm
Binary file not shown.
70 changes: 70 additions & 0 deletions i18n/jaxaEarthApi_en.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="en">
<context>
<name>Dialog</name>
<message>
<location filename="../jaxaEarthApiDialog.ui" line="14"/>
<source>JAXA Earth API</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../jaxaEarthApiDialog.ui" line="52"/>
<source>Details</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../jaxaEarthApiDialog.ui" line="68"/>
<source>Load</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../jaxaEarthApiDialog.ui" line="77"/>
<source>Filter-Date</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../jaxaEarthApiDialog.ui" line="184"/>
<source>yyyy/MM/dd</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../jaxaEarthApiDialog.ui" line="127"/>
<source>-&gt;</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>JaxaEarthApiDialog</name>
<message>
<location filename="../jaxaEarthApiDialog.py" line="116"/>
<source>Select Band</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../jaxaEarthApiDialog.py" line="121"/>
<source>-------- Global ------------</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../jaxaEarthApiDialog.py" line="125"/>
<source>--------- Local(Japan) ---------</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../jaxaEarthApiDialog.py" line="129"/>
<source>----------- Unknown -----------</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../jaxaEarthApiDialog.py" line="276"/>
<source>A period exceeding 1 year cannot be set.</source>
<translation>A period exceeding 1 year cannot be set.</translation>
</message>
<message>
<location filename="../jaxaEarthApiDialog.py" line="334"/>
<source>Error</source>
<translation type="unfinished"></translation>
</message>
</context>
</TS>
Binary file added i18n/jaxaEarthApi_ja.qm
Binary file not shown.
70 changes: 70 additions & 0 deletions i18n/jaxaEarthApi_ja.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="ja">
<context>
<name>Dialog</name>
<message>
<location filename="../jaxaEarthApiDialog.ui" line="14"/>
<source>JAXA Earth API</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../jaxaEarthApiDialog.ui" line="52"/>
<source>Details</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../jaxaEarthApiDialog.ui" line="68"/>
<source>Load</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../jaxaEarthApiDialog.ui" line="77"/>
<source>Filter-Date</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../jaxaEarthApiDialog.ui" line="184"/>
<source>yyyy/MM/dd</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../jaxaEarthApiDialog.ui" line="127"/>
<source>-&gt;</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>JaxaEarthApiDialog</name>
<message>
<location filename="../jaxaEarthApiDialog.py" line="116"/>
<source>Select Band</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../jaxaEarthApiDialog.py" line="121"/>
<source>-------- Global ------------</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../jaxaEarthApiDialog.py" line="125"/>
<source>--------- Local(Japan) ---------</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../jaxaEarthApiDialog.py" line="129"/>
<source>----------- Unknown -----------</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../jaxaEarthApiDialog.py" line="276"/>
<source>A period exceeding 1 year cannot be set.</source>
<translation type="unfinished">1年を超える期間を指定することは出来ません。</translation>
</message>
<message>
<location filename="../jaxaEarthApiDialog.py" line="334"/>
<source>Error</source>
<translation type="unfinished"></translation>
</message>
</context>
</TS>
2 changes: 1 addition & 1 deletion jaxaEarthApiDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ def load_dataset(self):
> 365 * 24 * 60 * 60
):
QMessageBox.information(
self, "Error", "1年を超える期間を指定することは出来ません。"
self, "Error", self.tr("A period exceeding 1 year cannot be set.", None)
)
return

Expand Down
13 changes: 12 additions & 1 deletion jaxaEarthApiPlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import os

# QGIS-API
from PyQt5.QtCore import *
from PyQt5.QtCore import QSettings, QTranslator, QCoreApplication
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from qgis.core import *
Expand All @@ -38,6 +38,17 @@ def __init__(self, iface):
self.toolbar.setObjectName(PLUGIN_NAME)
self.dialog = None
self.action = None
# initialize locale
locale = QSettings().value('locale/userLocale')[0:2]
locale_path = os.path.join(
self.plugin_dir,
'i18n',
'jaxaEarthApi_{}.qm'.format(locale))

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

def add_action(
self,
Expand Down
6 changes: 6 additions & 0 deletions jaxa_earth_api.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
SOURCES += jaxaEarthApiPlugin.py \
jaxaEarthApiDialog.py

FORMS += jaxaEarthApiDialog.ui

TRANSLATIONS = ./i18n/jaxaEarthApi_en.ts ./i18n/jaxaEarthApi_ja.ts

0 comments on commit 86ca2e1

Please sign in to comment.