Skip to content

Commit 6c51d10

Browse files
committed
Move the - to _ conversion
1 parent 1e9c752 commit 6c51d10

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/mkdocs_git_revision_date_localized_plugin/dates.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ def get_date_formats(
2222
assert time_zone is not None
2323
assert locale is not None
2424

25+
# Normalize locale for Babel: convert hyphens to underscores (e.g., pt-BR -> pt_BR)
26+
# This is needed for compatibility with mkdocs-static-i18n and other plugins
27+
# that may use hyphenated locale codes, while Babel expects underscores
28+
if locale:
29+
locale = str(locale).replace("-", "_")
30+
2531
utc_revision_date = datetime.fromtimestamp(int(unix_timestamp), tz=timezone.utc)
2632
loc_revision_date = utc_revision_date.replace(tzinfo=get_timezone("UTC")).astimezone(get_timezone(time_zone))
2733

src/mkdocs_git_revision_date_localized_plugin/plugin.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -291,12 +291,6 @@ def on_page_markdown(self, markdown: str, page: Page, config: config_options.Con
291291
if not locale:
292292
locale = self.config.get("locale")
293293

294-
# Normalize locale for Babel: convert hyphens to underscores (e.g., pt-BR -> pt_BR)
295-
# This is needed for compatibility with mkdocs-static-i18n and other plugins
296-
# that may use hyphenated locale codes, while Babel expects underscores
297-
if locale:
298-
locale = str(locale).replace("-", "_")
299-
300294
# Retrieve git commit timestamp
301295
# Except for generated pages (f.e. by mkdocs-gen-files plugin)
302296
if getattr(page.file, "generated_by", None):

0 commit comments

Comments
 (0)