fix warning in reges

bzr-revno: 2832
This commit is contained in:
thelinuxguy 2018-08-29 19:01:27 +01:00 committed by Tim Bentley
commit 2f465a9dd9
2 changed files with 13 additions and 3 deletions

View File

@ -271,9 +271,10 @@ class LanguageManager(object):
language = Settings().value('core/language')
language = str(language)
log.info("Language file: '{language}' Loaded from conf file".format(language=language))
if re.match(r'[[].*[]]', language):
m = re.match(r'\[(.*)\]', language)
if m:
LanguageManager.auto_language = True
language = re.sub(r'[\[\]]', '', language)
language = m.group(1)
return language
@staticmethod

View File

@ -27,7 +27,8 @@ from unittest.mock import MagicMock, patch
from openlp.core.common import is_macosx
from openlp.core.common.i18n import LANGUAGES, Language, UiStrings, get_language, get_locale_key, get_natural_key, \
translate
translate, LanguageManager
from openlp.core.common.settings import Settings
def test_languages_type():
@ -158,6 +159,14 @@ def test_check_same_instance():
assert first_instance is second_instance, 'Two UiStrings objects should be the same instance'
def test_get_language_from_settings():
assert LanguageManager.get_language() == 'en'
def test_get_language_from_settings_returns_unchanged_if_unknown_format():
Settings().setValue('core/language', '(foobar)')
assert LanguageManager.get_language() == '(foobar)'
def test_translate():
"""
Test the translate() function