mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-04-29 10:10:19 +00:00
mediawiki: Fix broken view on Bullseye due to language selection
Mediawiki on Bullseye ships with a different location for the Names.php file. This patch makes sure that the old location is also checked for the file. Signed-off-by: nbenedek <contact@nbenedek.me> [sunil: Fix checking if the file exists.] [sunil: Use similar paths for both versions of MediaWiki] Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
parent
3bba38c21d
commit
2da0d42409
@ -23,8 +23,15 @@ def get_skins():
|
|||||||
|
|
||||||
def get_languages():
|
def get_languages():
|
||||||
"""Return a list of available languages as choice field values."""
|
"""Return a list of available languages as choice field values."""
|
||||||
with open('/var/lib/mediawiki/includes/languages/data/Names.php',
|
# Names.php has different locations on Bullseye Bookworm
|
||||||
'r') as lang_file:
|
names_old = pathlib.Path('/usr/share/mediawiki/languages/data/Names.php')
|
||||||
|
names_new = pathlib.Path('/usr/share/mediawiki/includes/languages/'
|
||||||
|
'data/Names.php')
|
||||||
|
names_file = names_old
|
||||||
|
if not names_old.exists():
|
||||||
|
names_file = names_new
|
||||||
|
|
||||||
|
with open(names_file, 'r') as lang_file:
|
||||||
content = lang_file.read()
|
content = lang_file.read()
|
||||||
matches = re.findall(r"'([a-z_-]+)' => '(.+)', # .+", content)
|
matches = re.findall(r"'([a-z_-]+)' => '(.+)', # .+", content)
|
||||||
language_choices = [(code, name) for code, name in matches]
|
language_choices = [(code, name) for code, name in matches]
|
||||||
@ -75,5 +82,4 @@ class MediaWikiForm(forms.Form): # pylint: disable=W0232
|
|||||||
label=_('Default Language'), required=False,
|
label=_('Default Language'), required=False,
|
||||||
help_text=_('Choose a default language for your MediaWiki '
|
help_text=_('Choose a default language for your MediaWiki '
|
||||||
'installation. Users have the option to select '
|
'installation. Users have the option to select '
|
||||||
'their preferred language.'),
|
'their preferred language.'), choices=get_languages)
|
||||||
choices=get_languages)
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user