[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
@ -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…
x
Reference in New Issue
Block a user