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

This commit is contained in:
Óscar 2025-08-07 14:00:48 +02:00 committed by GitHub
parent 3a40ae5a83
commit 2064beae78
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 115 additions and 7 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) }}