Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tox translation build: add tests for lunr.js language support #2564

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/workflows/tox.yml
Expand Up @@ -99,6 +99,16 @@ jobs:
- name: Install Python dependencies
run: |
python -m pip install -r requirements/project.txt
- name: Check if the locales are supported by lunr.js
run: |
for locale in $(ls mkdocs/themes/mkdocs/locales/); do
if [[ "${locale}" != "en" ]]; then
if [[ ! -f "mkdocs/contrib/search/lunr-language/lunr.${locale}.js" ]]; then
echo "WARNING: locale '${locale}' is not supported by lunr.js"
fi
fi
done
shell: bash
- name: Check if Portable Object Templates should have been updated
run: |
python setup.py extract_messages -t mkdocs
Expand Down
7 changes: 4 additions & 3 deletions mkdocs/contrib/search/__init__.py
Expand Up @@ -22,11 +22,12 @@ def run_validation(self, value):
value = [value]
elif not isinstance(value, (list, tuple)):
raise config_options.ValidationError('Expected a list of language codes.')
for lang in value:
for lang in list(value):
if lang != 'en' and not self.lang_file_exists(lang):
raise config_options.ValidationError(
f'"{lang}" is not a supported language code.'
log.warning(
f'Ignoring search.lang "{lang}" as it is not a supported language code.'
)
value.remove(lang)
return value


Expand Down