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'
currentLocale = 'en'
SUPPORTED_LANGUAGES = ['de', 'en', 'es', 'fi', 'fr', 'it']
class PluginNotFound(Exception):
pass
@ -71,7 +72,7 @@ def import_conf():
global conf
conf = __import__('supybot.conf').conf
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' % (
', '.join(validStrings))
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
id for the language, such as 'en', 'fr', 'it' (without the quotes). If
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:
"""This is a hack to allow the i18n to get the current language, before