diff --git a/.github/workflows/tox.yml b/.github/workflows/tox.yml index 0e25a42080..0ec1e1f0df 100644 --- a/.github/workflows/tox.yml +++ b/.github/workflows/tox.yml @@ -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 diff --git a/mkdocs/contrib/search/__init__.py b/mkdocs/contrib/search/__init__.py index 1ca09863e0..0379cb6384 100644 --- a/mkdocs/contrib/search/__init__.py +++ b/mkdocs/contrib/search/__init__.py @@ -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