[plugins_translations] Update translations
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,26 +1,24 @@
|
|||||||
# -*- coding: utf-8 -*-
|
import logging
|
||||||
##
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from gajim.common import configpaths
|
from gajim.common import configpaths
|
||||||
|
|
||||||
from gajim.plugins import GajimPlugin
|
from gajim.plugins import GajimPlugin
|
||||||
from gajim.plugins.helpers import log_calls
|
|
||||||
from gajim.plugins.plugins_i18n import _
|
from gajim.plugins.plugins_i18n import _
|
||||||
|
|
||||||
|
log = logging.getLogger('gajim.p.plugins_translations')
|
||||||
|
|
||||||
|
|
||||||
class PluginsTranslationsPlugin(GajimPlugin):
|
class PluginsTranslationsPlugin(GajimPlugin):
|
||||||
|
|
||||||
@log_calls('PluginsTranslationsPlugin')
|
|
||||||
def init(self):
|
def init(self):
|
||||||
self.description = _('This plugin contains translation files '
|
self.description = _('This plugin contains translations for other '
|
||||||
'for Gajim plugins')
|
'Gajim plugins. Please restart Gajim after '
|
||||||
|
'enabling this plugin.')
|
||||||
self.config_dialog = None
|
self.config_dialog = None
|
||||||
self.config_default_values = {'last_version': '0'}
|
self.config_default_values = {'last_version': '0'}
|
||||||
self.locale_dir = os.path.join(
|
self.locale_dir = os.path.join(
|
||||||
configpaths.get('PLUGINS_USER'), 'locale')
|
configpaths.get('PLUGINS_USER'), 'locale')
|
||||||
|
|
||||||
@log_calls('PluginsTranslationsPlugin')
|
|
||||||
def activate(self):
|
def activate(self):
|
||||||
if self.config['last_version'] == self.version:
|
if self.config['last_version'] == self.version:
|
||||||
return
|
return
|
||||||
@@ -30,11 +28,14 @@ class PluginsTranslationsPlugin(GajimPlugin):
|
|||||||
files = glob(self.__path__ + '/*.mo')
|
files = glob(self.__path__ + '/*.mo')
|
||||||
|
|
||||||
# remove old data
|
# remove old data
|
||||||
self.remove_translations()
|
self._remove_translations()
|
||||||
|
|
||||||
# create dirs and copy files
|
# create dirs and copy files
|
||||||
os.mkdir(self.locale_dir)
|
os.mkdir(self.locale_dir)
|
||||||
locales = [os.path.splitext(os.path.basename(name))[0] for name in files]
|
locales = [
|
||||||
|
os.path.splitext(os.path.basename(name))[0] for name in files
|
||||||
|
]
|
||||||
|
log.info('Installing new translations...')
|
||||||
for locale in locales:
|
for locale in locales:
|
||||||
dst = os.path.join(os.path.join(self.locale_dir, locale),
|
dst = os.path.join(os.path.join(self.locale_dir, locale),
|
||||||
'LC_MESSAGES/gajim_plugins.mo')
|
'LC_MESSAGES/gajim_plugins.mo')
|
||||||
@@ -43,12 +44,12 @@ class PluginsTranslationsPlugin(GajimPlugin):
|
|||||||
|
|
||||||
self.config['last_version'] = self.version
|
self.config['last_version'] = self.version
|
||||||
|
|
||||||
def remove_translations(self):
|
def _remove_translations(self):
|
||||||
|
log.info('Removing old translations...')
|
||||||
if os.path.isdir(self.locale_dir):
|
if os.path.isdir(self.locale_dir):
|
||||||
import shutil
|
import shutil
|
||||||
shutil.rmtree(self.locale_dir)
|
shutil.rmtree(self.locale_dir)
|
||||||
|
|
||||||
@log_calls('PluginsTranslationsPlugin')
|
|
||||||
def deactivate(self):
|
def deactivate(self):
|
||||||
self.remove_translations()
|
self._remove_translations()
|
||||||
self.config['last_version'] = '0'
|
self.config['last_version'] = '0'
|
||||||
|
|||||||
Reference in New Issue
Block a user