Possibilities of using the date format

  • Hello Community!

    Before creating a new suggestion, I prefer to make sure and ask. Maybe there is a possibility with the date format that I don't know about.

    I'm trying to translate the Calendar to spanish and I have some 'problems' with dates because in Spanish the months can be written in upper and lower case (deppending use case).

    Is it possible to switch between upper and lower case via 'dateFormat' or is it only possible using the language file?

    I think a screenshot from Google Calendar will show you what I mean.

  • Aethior June 21, 2023 at 7:34 AM

    Changed the title of the thread from “Possibilities of use with the date format” to “Possibilities of using the date format”.
  • Hi

    because in Spanish the months can be written in upper and lower case (deppending use case).

    Can you elaborate on this a little?

    Generally speaking, date formatting beginning with WoltLab Suite 6.0 is delegated to PHP's / the web browsers Intl functionality that directly build on the relevant Unicode rules for the configured locale. The existing phrases are still available for compatibility (and possibly used in some places), but the majority of places should (hopefully) work correctly without doing anything fancy.

  • Hi Tim!

    Thank you for your reply and sorry for the delay. :)

    I'm going to start copying wcf.date.dateFormat and wcf.date.timeFormat in my Spanish language file.

    Code: es.xml
    <item name="wcf.date.dateFormat"><![CDATA[j \d\e F \d\e Y]]></item>
    <item name="wcf.date.timeFormat"><![CDATA[H:i]]></item>

    [*] Based on: https://es.wordpress.org/support/articl…-date-and-time/

    Hi

    I now specifically checked ICU's (Intl's) behavior for Spanish and it uses the lowercase month for a “Month + Year” combination, e.g. “junio de 2023”. According to https://meta.wikimedia.org/wiki/Capitaliz…_of_month_names this appears to be correct, because contrary to e.g. Croatian the “unless title” note is missing.

    You are right. In Spanish the months and the day of the weeks are not capitalised 21 de junio de 2023, unless they come at the beginning of a sentence (source). This is why Google Calendar uses Junio de 2023 above the sidebar calendar and 20 de junio de 2023 at the top of the page.

    So my question was whether there is a technical possibility to display the the month in upper or lower case using a format string (is this the right word?).

    At the beginning I wrote the month in upper case and now I have changed it to lower case in the language file (I had to choose one of the two ways).

    Code: es.xml
    <item name="wcf.date.month.june"><![CDATA[junio]]></item>

    In other words... To show the month in upper and lower case, as Google Calendar does, two language variables are needed? One in uppercase and other in lowercase?

  • Hi

    I'm going to start copying wcf.date.dateFormat and wcf.date.timeFormat in my Spanish language file.

    Yeah as indicated in my first post, those two phrases are effectively considered legacy beginning with WoltLab Suite 6.0, as the heavy lifting is done by the internationalization APIs of PHP and the web browser. Instead of needing to specify a format string within the list of phrases, we can just ask the Unicode library to “Format a Date + Time as appropriate for Spanish” or “Format a Month + Year as appropriate for Spanish” and it will automatically choose something. In the long run this will also improve flexibility to use appropriate formats in the appropriate locations without adding a multitude of phrases that are not necessary for most languages and insufficient for the remaining languages. For example in the calendar the headings are correctly constructed by two separate parts, one bare month-name part and the year part. This breaks down for languages that put the year first (i.e. 2023 June instead of June 2023).

    I've now specifically checked the Unicode data for Spanish (es). Both the regular variant:

    icu/icu4c/source/data/locales/es.txt at a9f75708929a2bd14f941f36aa36a7189d76a389 · unicode-org/icu
    The home of the ICU project source code. Contribute to unicode-org/icu development by creating an account on GitHub.
    github.com

    as well as the stand-alone variant (which is meant to be used for stuff like calendar headings):

    icu/icu4c/source/data/locales/es.txt at a9f75708929a2bd14f941f36aa36a7189d76a389 · unicode-org/icu
    The home of the ICU project source code. Contribute to unicode-org/icu development by creating an account on GitHub.
    github.com

    Use a lowercase month-name.

    Spanish as spoken in Peru (es-PE) uses uppercase names in the stand-alone variant, though:

    icu/icu4c/source/data/locales/es_PE.txt at a9f75708929a2bd14f941f36aa36a7189d76a389 · unicode-org/icu
    The home of the ICU project source code. Contribute to unicode-org/icu development by creating an account on GitHub.
    github.com

    The calendar is not yet adjusted to use the Intl API for formatting, but I've opened a draft change internally to check how it works. By delegating to Intl, it will result in this (i.e. lowercase):

    Is using a lowercase month name actually wrong here or is both upper- and lowercase acceptable for headlines? The former would imply that the official Unicode rules for Spanish would be incorrect :/

  • Hi Tim!

    First of all, thank you for the work you have done to review this problem.

    I have also been investigating how other software do it. In this case, the example to follow is Google Calendar. Google does it better than other.

    The correct form:

    Junio de 2023. Because it is the first word in the sentence.

    26 de junio de 2023. Because it is a word in the middle of the sentence.

    [*]de is a preposition.

    The same for the week days:

    Lunes, 26 de junio. Because it is the first word in the sentence.

    Hoy es lunes. (Today is Monday) Because it is a word in the middle/final of the sentence.

    Unless the capital letter is required by punctuation (at the beginning of the text or after a full stop), the names of the days of the week, the months and the seasons of the year are written in Spanish with an initial lower case. (...)

    In any case, I must admit that I think it is too bold to say that we have discovered a bug in Unicode. ?(

    Edit. In the last few days I have consulted a linguist. Even so, I am going to submit a query to the Royal Spanish Academy to put an end to the doubt.

    Edited once, last by Aethior (June 26, 2023 at 6:43 PM).

  • Hi

    yeah, I totally follow your examples. However a headline / title is not technically a sentence. You wouldn't use a full-stop at the end either. As an example, I did a Google search for “Spanish Calendar” and found this: https://depositphotos.com/218974406/stoc…an-spanish.html. Of course this is not an official source, but it uses lowercased titles for both the month and weekday.

    To give you an example of how the Intl API in PHP works, please have a look at this:

    PHP Sandbox - Execute PHP code online through your browser

    At the very top I configure the es_ES locale for Spanish in Spain. I can then ask it to give me an appropriate format string for “year + written month” (yMMMM) and it will turn this into MMMM 'de' y thus automatically including the “de” preposition!

    I've also tested the format for LLLL which is the standalone variant for the month name, but all variants return the month in lowercase.

    In any case, I must admit that I think it is too bold to say that we have discovered a bug in Unicode. ?(

    Yes, I would agree here. If this would actually be incorrect in the Unicode data files someone else must've discovered it before.

  • Hi

    I did some research and came across this:

    Unicode CLDR - Grammar & capitalization forms for date/time elements and others
    A. Issues There are at least 4 axes of variation for choosing the correct form of a date (or fragment thereof). Many of these issues also apply to choosing to…
    cldr.unicode.org

    My understanding is that this is a limitation in expressiveness of the CLDR definition language. In the big table you can see for Spanish + Month + Ia/Ib that uppercase is correct as you suggested. It's marked as orange, indicating that “might handle by fixing data (depends on client usage of format vs standalone)”.

    Unfortunately on our end we can't just uppercase the first character, because that would be incorrect for Danish and Finnish, which require months to always be lowercased even in headlines according to that table.

    I think that delegating the work to the Intl API is no worse than the current capabilities and also preferable to introducing a multitude of different, but similar phrases that translators need to deal with. If the Unicode CLDR data is improved, it would automatically apply when upgrading PHP. Would you agree with my conclusion?

  • I think I have caused you to receive a Spanish master class without expecting it. I also must confess that at times I have had doubts as to whether I was right.

    This is a current limitation of Unicode, it is possible that it will be corrected or improved in the future. As you can see, many online calendars in Spanish have this issue 'standardised'.

    I can only thank you for your involvement in getting to the bottom of this issue. ;)

  • Hi

    I think I have caused you to receive a Spanish master class without expecting it.

    Investigating this was most certainly more fun than quite of bit of other work. I always like being able to learn new stuff myself :)

    I also must confess that at times I have had doubts as to whether I was right.

    Language as used “colloquially” often differs from what is technically correct and then there's also regional variations that can add to the confusion. It's the same for German. One of the reasons we delegate to Intl / Unicode's CLDR data beginning with WoltLab Suite 6.0 is that those are maintained by experts and already include rules for pretty much all relevant languages and are also able to handle the edge cases of the languages. For example in Russian the words for the months are different depending on whether you refer to the month without a day (“stand-alone”) or to a specific date within a month (“format”).

    As you can see in the references I linked above, the CLDR data for Spanish (without including the country specific forms) is almost 3000 lines of information. German also has almost 3000 lines and Japanese clocks in at more than 4000 lines.

    This is a current limitation of Unicode, it is possible that it will be corrected or improved in the future.

    Okay. I'll move this thread to the suggestion section then. I'll hopefully be able complete the proof of concept integration for WoltLab Suite 6.0. The calendar for Spanish would look like the above screenshot then.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!