✨ feat: add per-language date format configuration (#556)
This commit is contained in:
10
config.toml
10
config.toml
@@ -238,6 +238,16 @@ code_block_name_links = true
|
||||
|
||||
|
||||
compact_tags = false
|
||||
|
||||
short_date_format = ""
|
||||
# Per-language date format overrides.
|
||||
# Examples: Spanish uses "3 de febrero de 2024", German uses "3. Februar 2024"
|
||||
date_formats = [
|
||||
{ lang = "ru", long = "%d %B %Y", short = "%-d %b %Y" },
|
||||
{ lang = "en", long = "%d. %B %Y", short = "%d.%m.%Y" },
|
||||
]
|
||||
|
||||
|
||||
tag_sorting = "frequency"
|
||||
|
||||
menu = [
|
||||
|
||||
@@ -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) }}
|
||||
|
||||
@@ -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 = "•"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user