diff --git a/mkdocs/localization.py b/mkdocs/localization.py index 5ec58077..c2eb6fb9 100644 --- a/mkdocs/localization.py +++ b/mkdocs/localization.py @@ -33,7 +33,7 @@ class NoBabelExtension(InternationalizationExtension): # pragma: no cover ) -def parse_locale(locale: str) -> Locale: +def parse_locale(locale) -> Locale: try: return Locale.parse(locale, sep='_') except (ValueError, UnknownLocaleError, TypeError) as e: diff --git a/mkdocs/tests/config/config_tests.py b/mkdocs/tests/config/config_tests.py index 7144e75f..e0981789 100644 --- a/mkdocs/tests/config/config_tests.py +++ b/mkdocs/tests/config/config_tests.py @@ -108,6 +108,7 @@ class ConfigTests(unittest.TestCase): 'dirs': [os.path.join(theme_dir, 'mkdocs'), mkdocs_templates_dir], 'static_templates': ['404.html', 'sitemap.xml'], 'vars': { + 'name': 'mkdocs', 'locale': parse_locale('en'), 'include_search_page': False, 'search_index_only': False, @@ -124,6 +125,7 @@ class ConfigTests(unittest.TestCase): 'dirs': [os.path.join(theme_dir, 'readthedocs'), mkdocs_templates_dir], 'static_templates': ['404.html', 'sitemap.xml'], 'vars': { + 'name': 'readthedocs', 'locale': parse_locale('en'), 'include_search_page': True, 'search_index_only': False, @@ -143,6 +145,7 @@ class ConfigTests(unittest.TestCase): 'dirs': [os.path.join(theme_dir, 'readthedocs'), mkdocs_templates_dir], 'static_templates': ['404.html', 'sitemap.xml'], 'vars': { + 'name': 'readthedocs', 'locale': parse_locale('en'), 'include_search_page': True, 'search_index_only': False, @@ -161,12 +164,13 @@ class ConfigTests(unittest.TestCase): { 'dirs': [mytheme, mkdocs_templates_dir], 'static_templates': ['sitemap.xml'], - 'vars': {'locale': parse_locale('en')}, + 'vars': {'name': None, 'locale': parse_locale('en')}, }, { 'dirs': [custom, os.path.join(theme_dir, 'readthedocs'), mkdocs_templates_dir], 'static_templates': ['404.html', 'sitemap.xml'], 'vars': { + 'name': 'readthedocs', 'locale': parse_locale('en'), 'include_search_page': True, 'search_index_only': False, @@ -186,6 +190,7 @@ class ConfigTests(unittest.TestCase): 'dirs': [os.path.join(theme_dir, 'mkdocs'), mkdocs_templates_dir], 'static_templates': ['404.html', 'sitemap.xml', 'foo.html'], 'vars': { + 'name': 'mkdocs', 'locale': parse_locale('fr'), 'show_sidebar': False, 'some_var': 'bar', diff --git a/mkdocs/tests/theme_tests.py b/mkdocs/tests/theme_tests.py index ad8a8d4f..213e2644 100644 --- a/mkdocs/tests/theme_tests.py +++ b/mkdocs/tests/theme_tests.py @@ -29,6 +29,7 @@ class ThemeTests(unittest.TestCase): self.assertEqual( get_vars(theme), { + 'name': 'mkdocs', 'locale': parse_locale('en'), 'include_search_page': False, 'search_index_only': False,