mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-02 22:48:40 +00:00
[i18n] Ignore non-translation dirs in get_languages
The `__pycache__` dir was showing up in list of available languages so ensure only those directories with languages are returned.
This commit is contained in:
parent
72d363968e
commit
1357ca7582
1 changed files with 7 additions and 1 deletions
|
@ -15,6 +15,7 @@ import locale
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
from glob import glob
|
||||||
|
|
||||||
from six.moves import builtins
|
from six.moves import builtins
|
||||||
|
|
||||||
|
@ -36,9 +37,14 @@ def get_languages():
|
||||||
lang = []
|
lang = []
|
||||||
|
|
||||||
translations_path = get_translations_path()
|
translations_path = get_translations_path()
|
||||||
|
lc_messages_path = os.path.join('LC_MESSAGES', I18N_DOMAIN + '.mo')
|
||||||
for root, dirs, files in os.walk(translations_path):
|
for root, dirs, files in os.walk(translations_path):
|
||||||
# Get the dirs
|
# Get the dirs
|
||||||
lang_dirs = dirs
|
lang_dirs = [
|
||||||
|
lang_dir
|
||||||
|
for lang_dir in dirs
|
||||||
|
if glob(os.path.join(translations_path, lang_dir, lc_messages_path))
|
||||||
|
]
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
return lang
|
return lang
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue