wizard: Check language is supported

Otherwise it may raise InvalidRegistryValue on first start
This commit is contained in:
Valentin Lorentz 2023-07-08 16:46:13 +02:00
parent 8d1d4b84eb
commit eb002a31e9
2 changed files with 4 additions and 2 deletions

View File

@ -50,6 +50,7 @@ MSGSTR = 'msgstr "'
FUZZY = '#, fuzzy' FUZZY = '#, fuzzy'
currentLocale = 'en' currentLocale = 'en'
SUPPORTED_LANGUAGES = ['de', 'en', 'es', 'fi', 'fr', 'it']
class PluginNotFound(Exception): class PluginNotFound(Exception):
pass pass
@ -71,7 +72,7 @@ def import_conf():
global conf global conf
conf = __import__('supybot.conf').conf conf = __import__('supybot.conf').conf
class Languages(conf.registry.OnlySomeStrings): class Languages(conf.registry.OnlySomeStrings):
validStrings = ['de', 'en', 'es', 'fi', 'fr', 'it'] validStrings = SUPPORTED_LANGUAGES
errormsg = 'Value should be a supported language (%s), not %%r' % ( errormsg = 'Value should be a supported language (%s), not %%r' % (
', '.join(validStrings)) ', '.join(validStrings))
conf.registerGlobalValue(conf.supybot, 'language', conf.registerGlobalValue(conf.supybot, 'language',

View File

@ -253,7 +253,8 @@ def _main():
language. This can be changed at any time. You need to answer with a short language. This can be changed at any time. You need to answer with a short
id for the language, such as 'en', 'fr', 'it' (without the quotes). If id for the language, such as 'en', 'fr', 'it' (without the quotes). If
you want to use English, just press enter.""") you want to use English, just press enter.""")
language = something('What language do you want to use?', default='en') language = expect('What language do you want to use?',
i18n.SUPPORTED_LANGUAGES, default='en')
class Empty: class Empty:
"""This is a hack to allow the i18n to get the current language, before """This is a hack to allow the i18n to get the current language, before