-
-
Notifications
You must be signed in to change notification settings - Fork 295
feat: support i18nMonth
for date in list item
#235
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
So as the comment in config.toml, hugo-theme-meme/config-examples/en/config.toml Lines 449 to 450 in a7c47aa
I don't think this is a bug. Though, it could be an enhancement. Also, in your code, if In other words, the character is |
i18nMonth
for date in list item
Ok, I understand the problem. For the moment, I don't known how fix it. |
New attempt to display i18n month in FR
2254ba4
to
535b7f6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds support for an i18nMonth
parameter to render translated month names in list items and handles a French-specific ordinal for the first day.
- Introduces a conditional on
.Site.Params.i18nMonth
- Extracts and translates the month via
i18n
- Applies a
<sup>er</sup>
suffix for French “1er” dates
Comments suppressed due to low confidence (1)
layouts/partials/utils/list-item.html:19
- This introduces a new
i18nMonth
config flag. Please update the project’s configuration reference or README to document this parameter and the expected translation keys for month names.
{{ if .Site.Params.i18nMonth }}
<time datetime="{{ .PublishDate.Format "2006-01-02T15:04:05-07:00" }}" class="list-item-time">{{ .PublishDate.Format .Site.Params.listDateFormat }}</time> | ||
<time datetime="{{ .PublishDate.Format "2006-01-02T15:04:05-07:00" }}" class="list-item-time"> | ||
{{ if .Site.Params.i18nMonth }} | ||
{{ $month := .PublishDate.Format "January" }}{{ $month := i18n (lower $month) }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Declaring $month
twice can be confusing and may shadow variables. Consider combining into a single statement, e.g.: {{ $month := i18n (lower .PublishDate.Format "January") }}
.
{{ $month := .PublishDate.Format "January" }}{{ $month := i18n (lower $month) }} | |
{{ $month := i18n (lower .PublishDate.Format "January") }} |
Copilot uses AI. Check for mistakes.
{{ if .Site.Params.i18nMonth }} | ||
{{ $month := .PublishDate.Format "January" }}{{ $month := i18n (lower $month) }} | ||
{{ $day := .PublishDate.Format "2" }} | ||
{{ if findRE "fr" .Site.LanguageCode }}{{ $day }}{{ if eq $day "1" }}<sup>er</sup>{{ end }} {{ $month }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using findRE
to detect the French locale can match unintended codes. Prefer hasPrefix
or a direct equality check, e.g.: {{ if hasPrefix .Site.LanguageCode "fr" }}
or {{ if eq .Site.LanguageCode "fr" }}
.
{{ if findRE "fr" .Site.LanguageCode }}{{ $day }}{{ if eq $day "1" }}<sup>er</sup>{{ end }} {{ $month }} | |
{{ if hasPrefix .Site.LanguageCode "fr" }}{{ $day }}{{ if eq $day "1" }}<sup>er</sup>{{ end }} {{ $month }} |
Copilot uses AI. Check for mistakes.
if i18n exists, the month into this list item is not correctly displayed. Actually, only in english.
With this fixe, month is displayed segun language code.