[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:
Calum Lind 2019-05-14 10:05:35 +01:00
parent 72d363968e
commit 1357ca7582
1 changed files with 7 additions and 1 deletions

View File

@ -15,6 +15,7 @@ import locale
import logging
import os
import sys
from glob import glob
from six.moves import builtins
@ -36,9 +37,14 @@ def get_languages():
lang = []
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):
# 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
else:
return lang