Re-work language check; add "Automatic" as default language

This commit is contained in:
Et0h 2014-12-02 21:07:17 +00:00
parent eecb5e04e4
commit 5122989d70
3 changed files with 14 additions and 5 deletions

View File

@ -167,6 +167,7 @@ en = {
"showslowdownosd-label" :"Include slowing down / reverting notification",
"showcontactinfo-label" : "Show contact info box",
"language-label" : "Language",
"automatic-language" : "Automatic",
"showdurationnotification-label" : "Warn about media duration mismatches",
"basics-label" : "Basics",
"sync-label" : "Sync",
@ -515,6 +516,7 @@ ru = {
"showslowdownosd-label" : u"Показывать уведомления о замедлении/перемотке",
"showcontactinfo-label" : u"Отображать контактную информацию разработчиков",
"language-label" : u"Language", # TODO: Translate ito Russian
"automatic-language" : "Automatic", # TODO: Translate ito Russian
"showdurationnotification-label" : u"Предупреждать о несовпадении продолжительности видео",
"basics-label" : u"Основное",
"sync-label" : u"Синхронизация",
@ -821,6 +823,7 @@ de = {
"showslowdownosd-label" : u"Zeige Verlangsamungs/Zurücksetzungs-Benachrichtigung",
"showcontactinfo-label" : u"Zeige Kontaktinformationen",
"language-label" : u"Sprache",
"automatic-language" : "Automatic", # TODO: Translate into German (Automatisch?)
"showdurationnotification-label" : u"Zeige Warnung wegen unterschiedlicher Dauer",
"basics-label" : u"Basics",
"sync-label" : u"Synchronisation",
@ -1007,6 +1010,9 @@ def getInitialLanguage():
initialLanguage = constants.FALLBACK_INITIAL_LANGUAGE
return initialLanguage
def isValidLanguage(language):
return messages.has_key(language)
def getMessage(type_, locale=None):
if constants.SHOW_BUTTON_LABELS == False:
if "-guibuttonlabel" in type_:
@ -1015,7 +1021,7 @@ def getMessage(type_, locale=None):
if "-tooltip" in type_:
return ""
if not messages.has_key(messages["CURRENT"]):
if not isValidLanguage(messages["CURRENT"]):
setLanguage(getInitialLanguage())
lang = messages["CURRENT"]

View File

@ -3,7 +3,7 @@ import argparse
import os
import sys
from syncplay import constants, utils, version, milestone
from syncplay.messages import getMessage, setLanguage
from syncplay.messages import getMessage, setLanguage, isValidLanguage
from syncplay.players.playerFactory import PlayerFactory
import codecs
try:
@ -116,6 +116,9 @@ class ConfigurationGetter(object):
self._config['language'] = language
raise InvalidConfigValue("*"+getMessage("config-cleared-notification"))
if not isValidLanguage(self._config['language']):
self._config['language'] = ""
def _isPortValid(varToTest):
try:
if varToTest == "" or varToTest is None:

View File

@ -5,7 +5,7 @@ from syncplay.players.playerFactory import PlayerFactory
import os
import sys
from syncplay.messages import getMessage, getLanguages, setLanguage, getInitialLanguage
from syncplay.messages import getMessage, getLanguages, setLanguage, isValidLanguage
from syncplay import constants
class GuiConfiguration:
@ -629,9 +629,9 @@ class ConfigDialog(QtGui.QDialog):
self.languageLabel = QLabel(getMessage("language-label"), self)
self.languageCombobox = QtGui.QComboBox(self)
self.languageCombobox.addItem(getMessage("automatic-language"))
self.languages = getLanguages()
if self.languages.has_key(self.config['language']) == False:
self.config['language'] = getInitialLanguage()
for lang in self.languages:
self.languageCombobox.addItem(self.languages[lang], lang)
if lang == self.config['language']: