feat: add per-language date format configuration (#556)

This commit is contained in:
2025-08-10 19:06:46 +07:00
parent 1f964e9b88
commit 762c309760
3 changed files with 35 additions and 1 deletions

View File

@@ -3,7 +3,23 @@
{#- Set locale -#}
{%- set date_locale = macros_translate::translate(key="date_locale", default="en_GB", language_strings=language_strings) -%}
{%- if config.extra.short_date_format and short -%}
{#- Check for language-specific date formats -#}
{%- set language_format = "" -%}
{%- if config.extra.date_formats -%}
{%- for format_config in config.extra.date_formats -%}
{%- if format_config.lang == lang -%}
{%- if short and format_config.short -%}
{%- set_global language_format = format_config.short -%}
{%- elif not short and format_config.long -%}
{%- set_global language_format = format_config.long -%}
{%- endif -%}
{%- endif -%}
{%- endfor -%}
{%- endif -%}
{%- if language_format -%}
{{ date | date(format=language_format, locale=date_locale) }}
{%- elif config.extra.short_date_format and short -%}
{{ date | date(format=config.extra.short_date_format, locale=date_locale) }}
{%- elif config.extra.long_date_format and not short -%}
{{ date | date(format=config.extra.long_date_format, locale=date_locale) }}

View File

@@ -184,6 +184,14 @@ quick_navigation_buttons = false
# Default is "6th July 2049" in English and "%-d %B %Y" in other languages.
short_date_format = ""
# Per-language date format overrides.
# Examples: Spanish uses "3 de febrero de 2024", German uses "3. Februar 2024"
# date_formats = [
# { lang = "es", long = "%d de %B de %Y", short = "%d %b %Y" },
# { lang = "de", long = "%d. %B %Y", short = "%d.%m.%Y" },
# ]
# Custom separator used in title tag and posts metadata (between date, time to read, and tags).
separator = "•"