Skip to content
This repository has been archived by the owner on Apr 5, 2022. It is now read-only.

Adjust language plural rules #263

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Adjust language plural rules #263

wants to merge 4 commits into from

Conversation

pacollins
Copy link
Owner

@pacollins pacollins commented Jul 4, 2021

Description

Using https://www.unicode.org/cldr/cldr-aux/charts/28/supplemental/language_plural_rules.html to update i18n for all languages.

Motivation and Context

Closes #233
Closes #225

Screenshots (if appropriate):

Checklist:

  • I have updated the documentation, as applicable.
  • I have updated the theme.toml, as applicable.

@@ -0,0 +1,3 @@
{{- $month_names := slice "Januari" "Februari" "Maart" "April" "Mei" "Juni" "Juli" "Augustus" "September" "Oktober" "November" "December" -}}
{{- $month := sub .Date.Month 1 -}}
{{ .Date.Day }} {{ index $month_names $month }} {{ .Date.Year }}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note to myself: missing EOL

@VincentTam
Copy link
Collaborator

I can add Chinese translations to month names. That's easy: cardinal number 🔢 + month 🌙. Lemme try this now.

@pacollins
Copy link
Owner Author

I was originally going to add them but didn't know if that was meaningful for Korean, Japanese, or Chinese since its just # Month. Is that common writing in Chinese, or is it more common to just do YYYY/MM/DD? If # Month isn't that common, then I see no issue with excluding that.

@VincentTam
Copy link
Collaborator

VincentTam commented Jul 19, 2021

I'll focus on my native language, and leave the Korean & Japanese part coz I've never learnt them.

As a Chinese l10n, I recommend using Arabic digits YYYY 年 MM 月 DD 日 (e.g 2021 年 7 月 19 日), or without the Chinese characters YYYY/MM/DD or DD/MM/YYYY. Any one of the three should work perfectly in daily situations. Here's the code for the 1st option.

<! -- layouts/_default/date/date.zh-tw.html -->
{{ .Date.Year }} 年 {{ .Date.Day }} 月 {{ .Date.Day }} 日

These three Chinese characters are the same in 🇹🇼 Traditional Chin. and 🇨🇳 Simplified Chin.


[TL;DR]

It's okay to put YYYY/MM/DD or DD/MM/YYYY, except in academic exams, which favor month names like "19th July, 2021" written in Chinese characters YYYY 年 MM 月 DD 日 (with YYYY converted digit by digit, and MM and DD converted as it's numeric value, for example "二零二一年七月十九日")---that's a nice Codingame programming question at beginner's level. I prefer Arabic digits "123" over Chinese characters "一二三" to avoid coding an array of Chinese characters and doing if-else statements. Here's the logic.

  1. Writing a mapping/dictionary from Arabic to Chinese characters$chin_num.
  2. Then use the $chin_num dictionary to convert YYYY (e.g.2021to 二零二一)
  3. month_names[month] 月
  4. switch $day
    • case <10: chin_num[day]
    • case 10-19: "十" + chin_num[day%10]
    • case >19: chin_num[day/10] + "十" + chin_num[day%10]

Unluckily, Hugo doesn't provide switch statements. Apart from lacking time to search for the right Hugo syntax for that, maintenance would be a challenge. I found both substr and slicestr for getting substrings. In case that one of them becomes deprecated, and I (or other contributor) would have to refactor the code.

<!-- I suggest using Arabic numerals with 年月日 instead of pure Chinese numerals as follow. -->
{{- $month_names := slice "一" "二" "三" "四" "五" "六" "七" "八" "九" "十" "十一" "十二" -}}
{{- $month := sub .Date.Month 1 -}}
{{ $day:= .Date.Day }}
{{ $year:= .Date.Year }}
{{- $chin_num := slice "零" "一" "二" "三" "四" "五" "六" "七" "八" "九" -}}
<!-- do logic here -->
<!-- render result -->

The three groups of Arabic digits YYYY, MM and DD can be separated by hyphen - or slash /.


From my experience, French month names begin with a small letter. A relevant Hugo page gives an example:
https://gohugo.io/content-management/multilingual/#customize-dates.

{{- $month_names := slice "Janvier" "Février" "Mars" "Avril" "Mai" "Juin" "Juillet" "Août" "Septembre" "Octobre" "Novembre" "Décembre" -}}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: Polish translation warnings BUG: Wrong date format for Spanish
2 participants