Skip to content

Commit

Permalink
Zip the preset translations. Unzip when launch
Browse files Browse the repository at this point in the history
  • Loading branch information
mcharzat committed Aug 5, 2021
1 parent 2320732 commit cd588ec
Show file tree
Hide file tree
Showing 38 changed files with 25 additions and 701,576 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

# QGIS-Plugin-CI
QuickOSM/i18n/
QuickOSM/resources/i18n/
QuickOSM.*.zip

# MkDocs
Expand Down
24 changes: 24 additions & 0 deletions QuickOSM/quick_osm.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
"""QuickOSM main entry point for setting up the UI, Processing."""

import logging
import os
import urllib.request

from os.path import join

from qgis.core import (
Qgis,
QgsApplication,
QgsCoordinateReferenceSystem,
QgsCoordinateTransform,
QgsProject,
QgsZipUtils,
)
from qgis.PyQt.QtCore import QCoreApplication, QTranslator, QUrl
from qgis.PyQt.QtGui import QDesktopServices, QIcon
Expand Down Expand Up @@ -66,6 +70,26 @@ def __init__(self, iface):
# LOGGER.info('Translation not found: {}'.format(locale))
pass

preset_translation_path = join(resources_path(), 'i18n')
if not os.path.isdir(preset_translation_path):
if os.path.isfile(preset_translation_path + '.zip'):
result = QgsZipUtils.unzip(preset_translation_path + '.zip', resources_path())
if not result[0]:
os.mkdir(preset_translation_path)
else:
LOGGER.info('Preset translations have been loaded and unzipped.')
files = os.listdir(preset_translation_path)
for file in files:
file_path = join(preset_translation_path, file)
if '-r' in file:
new_file_path = join(preset_translation_path, file.replace('-r', '_'))
os.rename(file_path, new_file_path)
elif '-' in file:
new_file_path = join(preset_translation_path, file.replace('-', '_'))
os.rename(file_path, new_file_path)
else:
os.mkdir(preset_translation_path)

self.provider = None

self.toolbar = None
Expand Down
Binary file added QuickOSM/resources/i18n.zip
Binary file not shown.
5 changes: 0 additions & 5 deletions QuickOSM/resources/i18n/README.md

This file was deleted.

Loading

0 comments on commit cd588ec

Please sign in to comment.