-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathi18n.py
More file actions
267 lines (214 loc) · 6.92 KB
/
Copy pathi18n.py
File metadata and controls
267 lines (214 loc) · 6.92 KB
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
# i18n.py
import os
from qgis.PyQt.QtCore import (
QCoreApplication,
QSettings,
QTranslator,
QT_VERSION_STR
)
class TR:
@staticmethod
def X3_MESH():
return QCoreApplication.translate("jpData", "3rd Mesh")
@staticmethod
def X4_MESH():
return QCoreApplication.translate("jpData", "4th Mesh")
@staticmethod
def X5_MESH():
return QCoreApplication.translate("jpData", "5th Mesh")
@staticmethod
def X6_MESH():
return QCoreApplication.translate("jpData", "6th Mesh")
@staticmethod
def ADDRESS():
return QCoreApplication.translate("jpData", "Address")
@staticmethod
def ADDRESS_MISSING():
return QCoreApplication.translate(
"jpData",
"Address data is missing"
)
@staticmethod
def ADD_TO_MAP():
return QCoreApplication.translate("jpData", "Add to Map")
@staticmethod
def ADD_TO_MAP_TOOLTIP():
return QCoreApplication.translate(
"jpData",
"Add Shapefile as a Layer to Map on QGIS"
)
@staticmethod
def CANCEL():
return QCoreApplication.translate("jpData", "Cancel")
@staticmethod
def CANCELLED():
return QCoreApplication.translate("jpData", "...Cancelled")
@staticmethod
def CENSUS():
return QCoreApplication.translate("jpData", "Census")
@staticmethod
def CENSUS_TYPE_TOOLTIP():
return QCoreApplication.translate(
"jpData",
"Nieghbourhood: population of cho, aza, etc.<br />3rd Mesh: 1 km mesh<br />4th Mesh: 500 m mesh<br />5th Mesh: 250 m mesh",
)
@staticmethod
def CENSUS_YEAR_TOOLTIP():
return QCoreApplication.translate(
"jpData",
"Nieghbourhood: Since 2000<br />1st throught 3rd: Since 1995<br />5th Mesh: Since2005<br />6th Mesh: Since2015",
)
@staticmethod
def CHOOSE_FOLDER():
return QCoreApplication.translate("jpData", "Choose Folder")
@staticmethod
def CHOOSE_FOLDER_INIT():
return QCoreApplication.translate(
"jpData",
"Choose folder for zip/shp files"
)
@staticmethod
def CHOOSE_MAP_TYPE():
return QCoreApplication.translate("jpData", "Choose a map type")
@staticmethod
def CHOOSE_MESH():
return QCoreApplication.translate("jpData", "Choose a mesh code")
@staticmethod
def CHOOSE_MUNICIPALITY():
return QCoreApplication.translate(
"jpData",
"Choose a municipality"
)
@staticmethod
def CHOOSE_PREFECTURE():
return QCoreApplication.translate(
"jpData",
"Choose a prefecture"
)
@staticmethod
def CHOOSE_PREFECTURE_REGION():
return QCoreApplication.translate(
"jpData",
"Choose a prefecture or region"
)
@staticmethod
def DONE():
return QCoreApplication.translate("jpData", "...Done")
@staticmethod
def DOWNLOAD():
return QCoreApplication.translate("jpData", "Download")
@staticmethod
def DOWNLOAD_CENSUS():
return QCoreApplication.translate(
"jpData",
"Download census data by city"
)
@staticmethod
def DOWNLOAD_LNI():
return QCoreApplication.translate(
"jpData",
"Download Land Numerical Information data"
)
@staticmethod
def GSI_TILES():
return QCoreApplication.translate("jpData", "GSI Tiles")
@staticmethod
def GSI_TILES_TOOLTIP():
return QCoreApplication.translate(
"jpData",
"Add GSI xyz tile server to Map on QGIS"
)
@staticmethod
def JUMP():
return QCoreApplication.translate("jpData", "Jump")
@staticmethod
def LANDNUMINFO():
return QCoreApplication.translate("jpData", "LandNumInfo")
@staticmethod
def MHLW():
return QCoreApplication.translate("jpData", "MHLW")
@staticmethod
def NATIONWIDE():
return QCoreApplication.translate("jpData", "Nation-wide")
@staticmethod
def NEIGHBOURHOOD():
return QCoreApplication.translate("jpData", "Neighbourhood")
@staticmethod
def RUN():
return QCoreApplication.translate("jpData", "Run")
@staticmethod
def SETTING():
return QCoreApplication.translate("jpData", "Setting")
@staticmethod
def SETTING_BACKGROUND():
return QCoreApplication.translate(
"jpData",
"Turn off background download"
)
@staticmethod
def SETTING_GEOMETRY():
return QCoreApplication.translate(
"jpData",
"Check geometry validity when adding layers"
)
@staticmethod
def WEB():
return QCoreApplication.translate("jpData", "Web")
@staticmethod
def WEB_TOOLTIP():
return QCoreApplication.translate(
"jpData",
"Open the webpage with the standard browser"
)
@staticmethod
def YEAR():
return QCoreApplication.translate("jpData", "Year")
@staticmethod
def CANNOT_FIND_FILE(name):
template = QCoreApplication.translate("jpData", "Cannot find file: %1")
return template.replace("%1", str(name))
@staticmethod
def CANNOT_FIND_FILE_LAYER(name):
template = QCoreApplication.translate(
"jpData", "Cannot find the file for layer: %1"
)
return template.replace("%1", str(name))
@staticmethod
def CANNOT_LOAD_LAYER(name):
template = QCoreApplication.translate("jpData", "Cannot load the layer: %1")
return template.replace("%1", str(name))
@staticmethod
def DOWNLOADING(name):
template = QCoreApplication.translate("jpData", "Downloading: %1")
return template.replace("%1", str(name))
@staticmethod
def FILE_EXISTS(name):
template = QCoreApplication.translate("jpData", "The file already exists: %1")
return template.replace("%1", str(name))
@staticmethod
def INVALID_EPSG(value):
template = QCoreApplication.translate(
"jpData", "Invalid EPSG: %1. Uses default instead."
)
return template.replace("%1", str(value))
@staticmethod
def INVALID_GEOM(value):
template = QCoreApplication.translate(
"jpData", "The layer has %1 invalid geometries."
)
return template.replace("%1", str(value))
def setup_translation(plugin_dir, plugin_name):
locale = QSettings().value('locale/userLocale')[0:2]
qt_major = QT_VERSION_STR.split('.')[0]
locale_path = os.path.join(
plugin_dir,
'i18n',
f'qt{qt_major}',
f'{plugin_name}_{locale}.qm'
)
if os.path.exists(locale_path):
translator = QTranslator()
translator.load(locale_path)
QCoreApplication.installTranslator(translator)
return translator
return None