Cinnamon: Wrong date format on non-English locales

Created on 21 Dec 2019  ·  38Comments  ·  Source: linuxmint/cinnamon

```

  • Cinnamon version: 4.4.5
  • Distribution: Mint 19.3 (updated from 19.2)
  • Graphics hardware and driver used: just Intel
  • 64 bit
    ```

Issue
Wrong date format, not as per LC_TIME=zh_CN.UTF-8
2019-12-21 18-06-14屏幕截图

Steps to reproduce

*Change locale other than English (US)
*Check the calendar applet or uncheck "Internet time" box on Date & Time setting to see the date format

Expected behaviour

The previous Cinnamon version that shipped with 19.2 DOES NOT occur with this bug.

Most helpful comment

Fixed in Cinnamon 4.4.8

All 38 comments

can you paste the output of locale and apt version libcinnamon-desktop4?

Also, write down in Chinese the expected date and explain its components (month, week, day..) so we can troubleshoot what's happening.

My libcinnamon-desktop4 version is 4.4.1, the locale command shows zh_CN.UTF-8 is on strings except LANGUAGE (zh_CN) and LC_ALL (blank) .

The expected date in Chinese with Ruby date syntax is: %Y年%b%d日 %A (a la YYYY/MM/DD *day)

I can confirm a similar bug for locale LC_TIME=sr_RS@latin. I have the interface language set to en_US UTF-8 and the Region and Time Format set to sr_RS@latin. I have the same version of libcinnamon-desktop4 (4.4.1). The expected date format in Serbian (Latin) is correct in /usr/share/i18n/locales/sr_RS@latin (%A, %d. %B %Y.), but in Calendar applet (and tooltip) it shows the en_US date format (%A %B %e %Y) literally translated into Serbian (Latin) language

Similar bug for LC_TIME=fr_FR.UTF-8. The calendar shows Dimanche 22 décembre, 2019 (title and tooltip) instead of Dimanche 22 décembre 2019 as expected.

Same bug in Polish, its now: "DayOfTheWeek monthName, dayNumber, yearNumber", dunno how it was in 19.2 but it should be: "DayOfTheWeek dayNumber monthName yearNumber"
LANG=pl_PL.UTF-8 LANGUAGE=pl_PL:pl LC_CTYPE="pl_PL.UTF-8" LC_NUMERIC=pl_PL.UTF-8 LC_TIME=pl_PL.UTF-8 LC_COLLATE="pl_PL.UTF-8" LC_MONETARY=pl_PL.UTF-8 LC_MESSAGES="pl_PL.UTF-8" LC_PAPER=pl_PL.UTF-8 LC_NAME=pl_PL.UTF-8 LC_ADDRESS=pl_PL.UTF-8 LC_TELEPHONE=pl_PL.UTF-8 LC_MEASUREMENT=pl_PL.UTF-8 LC_IDENTIFICATION=pl_PL.UTF-8 LC_ALL= 4.4.1+tricia

Similar bug for LC_TIME=fr_FR.UTF-8. The calendar shows Dimanche 22 décembre, 2019 (title and tooltip) instead of Dimanche 22 décembre 2019 as expected.

I didn’t know that the comma was a mistake. That’s what it shows on mine with the french canadian language with 19.3

Wrong date format here as well. In the calendar pop-up/applet it's "day month date, year" when it should be "day, date month year". And directly in the system tray the year was missing.

Reference: IBM Knowledge Center

$ locale
LANG=ro_RO.UTF-8
LANGUAGE=ro_RO
LC_CTYPE="ro_RO.UTF-8"
LC_NUMERIC=ro_RO.UTF-8
LC_TIME=ro_RO.UTF-8
LC_COLLATE="ro_RO.UTF-8"
LC_MONETARY=ro_RO.UTF-8
LC_MESSAGES="ro_RO.UTF-8"
LC_PAPER=ro_RO.UTF-8
LC_NAME=ro_RO.UTF-8
LC_ADDRESS=ro_RO.UTF-8
LC_TELEPHONE=ro_RO.UTF-8
LC_MEASUREMENT=ro_RO.UTF-8
LC_IDENTIFICATION=ro_RO.UTF-8
LC_ALL=

$ apt version libcinnamon-desktop4
4.4.1+tricia

OK back to the drawing board on this one... I'll troubleshoot my own locale:

LANG=fr_FR.UTF-8
LANGUAGE=fr_FR
LC_CTYPE="fr_FR.UTF-8"
LC_NUMERIC=fr_FR.UTF-8
LC_TIME=fr_FR.UTF-8
LC_COLLATE="fr_FR.UTF-8"
LC_MONETARY=fr_FR.UTF-8
LC_MESSAGES="fr_FR.UTF-8"
LC_PAPER=fr_FR.UTF-8
LC_NAME=fr_FR.UTF-8
LC_ADDRESS=fr_FR.UTF-8
LC_TELEPHONE=fr_FR.UTF-8
LC_MEASUREMENT=fr_FR.UTF-8
LC_IDENTIFICATION=fr_FR.UTF-8
LC_ALL=

Source code:

The relevant code in the applet is:

this._dateFormatFull = CinnamonDesktop.WallClock.lctime_format("cinnamon", "%A %B %-e, %Y");
let dateFormattedFull = this.clock.get_clock_for_format(this._dateFormatFull).capitalize();
this.set_applet_tooltip(dateFormattedFull);

Which calls these two functions in libcinnamon-desktop:

/**
 * gnome_wall_clock_lctime_format:
 * @clock: The GnomeWallClock
 * @gettext_domain: (nullable)
 * @format_string: (nullable)
 *
 * Returns the translation of the format string according to
 * the LC_TIME locale.
 *
 * Returns: (transfer none): The translated format string.
 **/
gchar *
gnome_wall_clock_lctime_format (const gchar * gettext_domain, const gchar * format_string)
{
  const gchar *env_language, *env_lc_time;
  gchar *string;
  gboolean   use_lctime;

  /* Use LC_TIME if it's set and different than LANGUAGE */
  env_language = g_getenv("LANGUAGE");
  env_lc_time = g_getenv("LC_TIME");

  use_lctime = (env_language != NULL) && (env_lc_time != NULL) && (g_strcmp0 (env_language, env_lc_time) != 0);

  if (use_lctime) {
    /* Set LANGUAGE to the LC_TIME value, so we can get the right date format via gettext */
    g_setenv("LANGUAGE", env_lc_time, TRUE);
  }

  string = dgettext(gettext_domain, format_string);

  if (use_lctime) {
    /* Set back LANGUAGE the way it was before */
    g_setenv("LANGUAGE", env_language, TRUE);
  }

  return string;
}

and

/**
 * gnome_wall_clock_get_clock_for_format:
 * @clock: The GnomeWallClock
 * @format_string: (not nullable)
 *
 * Returns a formatted date and time based on the provided format string.
 * The returned string should be ready to be set on a label.
 *
 * Returns: (transfer full): The formatted date/time string, or NULL
 * if there was a problem with the format string.
 **/
gchar *
gnome_wall_clock_get_clock_for_format (GnomeWallClock *clock,
                                       const gchar    *format_string)
{
    gchar *ret;
    GDateTime *now;

    g_return_val_if_fail (format_string != NULL, NULL);

    now = g_date_time_new_now_local ();
    ret = g_date_time_format (now, format_string);

    g_date_time_unref (now);

    return ret;
}

Translations:

The relevant translation here is Cinnamon's FR mo file in /usr/share/locale/fr/LC_MESSAGES/cinnamon.mo, let's extract it into a po file with:

msgunfmt /usr/share/locale/fr/LC_MESSAGES/cinnamon.mo > cinnamon.po

In the resulting file, we look up %A %B %-e, %Y and we get:

msgid "%A %B %-e, %Y"
msgstr "%A %e %B, %Y"

Execution:

When we call this._dateFormatFull = CinnamonDesktop.WallClock.lctime_format("cinnamon", "%A %B %-e, %Y");, our LANGUAGE and LC_TIME don't match (and that could be a bug... because they both are fr_FR.. but one has the UTF-8 suffix, and the other one doesn't..).

Anyway, so when we call this, LANGUAGE is given the value fr_FR.UTF-8 and we then call gettext to get the translations for %A %B %-e, %Y.

According to our translations, this should return %A %e %B, %Y.

By the time we call g_date_time_format, we're getting day and month names according to LC_TIME, so everything's in French, but in the format we specified (%A %e %B, %Y).

So in the case of @claudiux and @gillcar here, this isn't a bug. Dimanche 22 décembre, 2019 is correct.

It looks like the issue is with incomplete translations. All I'm getting is this:

Name=%A %B %-e, %Y
Name[da]=%A %-e. %B %Y
Name[de]=%A, %e. %B %Y
Name[fr]=%A %e %B, %Y
Name[fr_CA]=%A %e %B, %Y
Name[hr]=%A %-e %B, %Y
Name[hu]=%Y. %B %e., %A
Name[lt]=%Y %B %-e, %A
Name[tr]=%-e %B %A , %Y

For any other languages, if there's no translation for %A %B %-e, %Y, you'll get %A %B %-e, %Y... which is basically the US date format.

Here's zh_CN not translated for instance: https://translations.launchpad.net/linuxmint/latest/+pots/cinnamon/zh_CN/443/+translate.

Note that it might be translated in some languages in Launchpad and not yet pushed towards cinnamon-translations (cinnamon-l10n). In cinnamon-l10n 4.4.1, only translations for da, de, fr, fr_CA, hr, hu, lt and tr are present apparently.

Thank you Clem for clearing this out. I am not a coder, but as I used to translate a lot from English into Serbian and vice versa, I took the liberty to sign up to the Serbian Translation Team for Linux Mint and proposed a missing translation for line 443 in Template "cinnamon" for Serbian Latin (sr@latin) language. By the way, I had no idea how much translation is missing for this specific language. I'll have to make a New Year's resolution to translate as much as I can in 2020 :)

OK back to the drawing board on this one... I'll troubleshoot my own locale:

Thanks, I started updating the Romanian translation. :grin:

I have 19.3, but I feel that I have this format "issue" since 18.2 when I started using linux. I have the time format (in Language Settings) set to English, United Kingdom, even though I live in Czech Republic, I like my system in English.
The command date gives me: Sat 4 Jan 01:31:06 CET 2020
But the clock hover and header say: Saturday January 4, 2020
Of course I would like to have here: Saturday 4 January, 2020
Or even better, to have the possibility to set up the format, like in "World Clock Calendar" that I use. It lets me have a custom time on the panel and even for individual time zones. Heaving this for the Date and Time Settings would be nice.
This is not a major bug, but it surely is weird and there for a long time.
Thank you for investigating this.

I was just checking what seems the standard date format in Quebec, Canada and found a few examples like this one https://www.timeanddate.com/worldclock/canada/quebec
With no comma between the month and year

@claudiux you made a mistake.. it should be %A %e %B %Y

@clefebvre Sorry. This is corrected.
EDIT: %A %-e %B %Y

I'll go through the main locales today and issue an update.

I'll use the formats available at http://www.localeplanet.com/icu/en/ as a reference.

Following the information available at https://www.localeplanet.com/compare/date-pattern.html?pat=FULL, I came up with the following formats:

en_US, en_CA: %A, %B %-e, %Y
en_ZA: %A %d %B %Y
fr, fr_CA, it, nl, he: %A %-e %B %Y
ro, el, pl, en_GB, en_NZ, en_AU: %A, %-e %B %Y
sk: %A, %Y, %B %-e
es, pt, pt_BR: %A, %-e de %B de %Y
de, sl, et: %A, %-e. %B %Y
cs: %A %-e. %B %Y
sr: %A, %d. %B %Y
ru: %A, %-e %B %Y г.
da: %A den %-e. %B %Y
tr: %-e %B %Y %A
hu: %Y. %B %-e.
fi, no: %-e. %B %Y
se: den %-e %B %Y
uk: %A, %-e %B %Y р.
vi: %A, ngày %d %B năm %Y
zh: %Y年%m月%-e日 %A
ja: %Y年%m月%-e日
ko: %Y년 %m월 d일 %A
hr: %Y. %B %d

Great...

I didn't really understand how to translate the Thai format into strftime... the year in particular, if anyone from Thailand can help with that, we can add it in before the next update.

uk: %A, %-e %B %Y р.

Is it just me, or is there an extra p. at the end? That would be just an extra am/pm right?
PS: Not sure how %-e and %e are different. I was using www.foragoodstrftime.com as reference.

%-e means non-padded and no leading zero. The p. comes from http://www.localeplanet.com/compare/date-pattern.html?pat=FULL

Fixed in cinnamon 4.4.7 and cinnamon-l10n 4.4.2 for the following locales:

Name=%A, %B %-e, %Y
Name[bg]=%d %B %Y, %A
Name[ca]=%A, %-e / %B / %Y
Name[ca@valencia]=%A, %-e / %B / %Y
Name[cs]=%A %-e. %B %Y
Name[da]=%A den %-e. %B %Y
Name[de]=%A, %-e. %B %Y
Name[el]=%A, %-e %B %Y
Name[en_AU]=%A, %-e %B %Y
Name[en_GB]=%A, %-e %B %Y
Name[en_IE]=%A, %-e %B %Y
Name[en_NZ]=%A, %-e %B %Y
Name[en_ZA]=%A %d %B %Y
Name[es]=%A, %-e de %B de %Y
Name[es_AR]=%A, %-e de %B de %Y
Name[et]=%A, %-e. %B %Y
Name[eu]=%Y(e)ko %Bk %-e, %A
Name[fi]=%-e. %B %Y
Name[fr]=%A %-e %B %Y
Name[fr_CA]=%A %-e %B %Y
Name[he]=%A %-e %B %Y
Name[hr]=%Y. %B %d
Name[hu]=%Y. %B %-e., %A
Name[it]=%A %-e %B %Y
Name[ja]=%Y年%m月%-e日
Name[ko]=%Y년 %m월 d일 %A
Name[lt]=%Y %B %-e, %A
Name[nb]=%-e. %B %Y
Name[nl]=%A %-e %B %Y
Name[nn]=%-e. %B %Y
Name[no]=%-e. %B %Y
Name[pl]=%A, %-e %B %Y
Name[pt]=%A, %-e de %B de %Y
Name[pt_BR]=%A, %-e de %B de %Y
Name[ro]=%A, %-e %B %Y
Name[ru]=%A, %-e %B %Y г.
Name[sk]=%A, %Y, %B %-e
Name[sl]=%A, %-e. %B %Y
Name[sr]=%A, %d. %B %Y
Name[sr@ijekavianlatin]=%A, %d. %B %Y
Name[sr@latin]=%A, %d. %B %Y
Name[sv]=den %-e %B %Y
Name[tr]=%-e %B %Y %A
Name[uk]=%A, %-e %B %Y р.
Name[vi]=%A, ngày %d %B năm %Y
Name[zh_CN]=%Y年%m月%-e日 %A
Name[zh_HK]=%Y年%m月%-e日 %A
Name[zh_TW]=%Y年%m月%-e日 %A

for any other locale, please translate at https://translations.launchpad.net/linuxmint/latest/+pots/cinnamon

After the update and even restart, with the new update to cinnamon 4.4.7, with a UK time format in my language settings, the header and hover on the calendar app is still "Monday January 6, 2020"

Sadly, here also the issue remains, for language Serbian, Serbia UTF8@latin... BTW, even the Cyrillic version of the Serbian language, which is 99.9% translated, has this same bug.

no, fr should be enough... we don't need fr_FR.

I must have missed something.. you're still getting the old en_US msgid.. this changed to having two comas in 4.4.7.

Capture du 2020-01-06 18-23-23

$ locale
LANG=fr_FR.UTF-8
LANGUAGE=fr_FR
LC_CTYPE="fr_FR.UTF-8"
LC_NUMERIC=fr_FR.UTF-8
LC_TIME=fr_FR.UTF-8
LC_COLLATE="fr_FR.UTF-8"
LC_MONETARY=fr_FR.UTF-8
LC_MESSAGES="fr_FR.UTF-8"
LC_PAPER=fr_FR.UTF-8
LC_NAME=fr_FR.UTF-8
LC_ADDRESS=fr_FR.UTF-8
LC_TELEPHONE=fr_FR.UTF-8
LC_MEASUREMENT=fr_FR.UTF-8
LC_IDENTIFICATION=fr_FR.UTF-8
LC_ALL=

yes, but we don't need fr_FR mo files... fr_XX should match fr.mo if it doesn't match fr_XX.mo specifically. So for instance, we only need an fr_CA to define strings which aren't the same as in fr... and we never need an fr_FR, since fr itself covers it entirely.

I can reproduce the issue, I'll get it fixed tomorrow.

OK, it's silly, it's a missing change in the clock applet itself. I can't do it tonight, but it'll be an easy fix tomorrow morning.

Fixed in Cinnamon 4.4.8

Yesss! It works well, now.

Ah, yes, on the calendar app it works. I was hoping it would work also on "world clock calendar" ^^ It looked the same there. I guess it's an app specific thing...? Well, can't be helped.

Was this page helpful?
0 / 5 - 0 ratings