Skip to content

Commit b0ab74f

Browse files
authored
backwards compatible theme locale access
1 parent 530e842 commit b0ab74f

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

mkdocs_git_revision_date_localized_plugin/plugin.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,18 @@
44
https://www.mkdocs.org/
55
https://github.com/timvink/mkdocs-git-revision-date-localized-plugin/
66
"""
7-
# standard lib
87
import logging
98
import re
109
import os
1110
import time
1211

13-
# 3rd party
12+
from mkdocs import __version__ as mkdocs_version
1413
from mkdocs.config import config_options
1514
from mkdocs.plugins import BasePlugin
1615
from mkdocs.structure.nav import Page
1716
from mkdocs.utils import copy_file
1817
from mkdocs.exceptions import ConfigurationError
1918

20-
# package modules
2119
from mkdocs_git_revision_date_localized_plugin.util import Util
2220
from mkdocs_git_revision_date_localized_plugin.exclude import exclude
2321

@@ -26,7 +24,6 @@
2624

2725
HERE = os.path.dirname(os.path.abspath(__file__))
2826

29-
3027
class GitRevisionDateLocalizedPlugin(BasePlugin):
3128
"""
3229
Mkdocs plugin to add revision date from Git.
@@ -79,7 +76,7 @@ def on_config(self, config: config_options.Config, **kwargs) -> Dict[str, Any]:
7976
# theme locale
8077
if "theme" in config and "locale" in config.get("theme"):
8178
custom_theme = config.get("theme")
82-
theme_locale = custom_theme.locale
79+
theme_locale = custom_theme.locale if mkdocs_version >= "1.6.0" else custom_theme._vars.get("locale")
8380
logging.debug(
8481
"Locale '%s' extracted from the custom theme: '%s'"
8582
% (theme_locale, custom_theme.name)

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
setup(
1414
name="mkdocs-git-revision-date-localized-plugin",
15-
version="1.2.4",
15+
version="1.2.5",
1616
description="Mkdocs plugin that enables displaying the localized date of the last git modification of a markdown file.",
1717
long_description=LONG_DESCRIPTION,
1818
long_description_content_type="text/markdown",

0 commit comments

Comments
 (0)