"D" represents the abbreviated weekday, usually the first three letters (in English: "Mon" through "Sun").
However, in some countries of the world, this way of abbreviating weekdays is not common or not used at all.
In Germany, for example, we are abbreviating weekdays always using the first two letters (German: "Mo" - "So"). This is reflected in the German Drupal core translation, where "Mon" through "Sun" is translated with "Mo" through "So".
Date module obviously works differently: It puts the full weekday ("Monday" through "Sunday") through the translation (resulting in "Montag" through "Sonntag"), and then uses the first three letters of the translation.
While this might be technically correct, the result is poor and not overwriteable. Please give back control to the translators: strip the weekdays first to "Mon" through "Sun", and send them only then through the translation process! Thanks!
| Comment | File | Size | Author |
|---|---|---|---|
| #20 | date_php4-dev20090310.diff | 1.95 KB | emok |
| #16 | date.patch | 7.73 KB | karens |
| #1 | weekday_abbreviations.patch | 1.44 KB | pancho |
Comments
Comment #1
panchoFrom what I found out, at least the following languages are affected: Czech, Danish, Dutch, Euskera, Finnish, German, Hungarian, Polish, Slovakian. At least in Polish language, the abbreviations are not even the first two letters.
I found issue #256079 where it was suggested to abbreviate the already translated weekday strings. This decision needs to be reverted.
One point remains valid though: it is simply not possible to translate single character abbreviations. For this special case ($length=1) we need to make an exception and use the already translated strings. We can safely assume that in every single language of the world at least the first character of every weekday is also the first character in the weekday's abbreviation.
I've not yet taken month names into account which are a bit less problematic.
Enclosed is a patch fixing this issue in date_week_days_abbr() and date_t().
Comment #2
robertgarrigos commentedCatalan also uses two-three letters for weekdays abbreviation and they are not necessarily the first characters:
Dll (Dilluns)
Dmt (Dimarts)
Dmc (Dimecres)
Dj (Dijous)
Dv (Divendres)
Ds (Dissabte)
Dmg (Diumenge)
So I don't thing even this patch would help us. Wouldn't be easier to have a setting for this?
Comment #3
karens commentedI don't want to eliminate the possibilities of being able to use the first letter or the first two letters, but for the abbreviation we can go back to a regular translation method used in core. In D6 core has a special flag for the full month name to distinguish it from the abbreviation.
Can you re-roll the patch to work that way?
Comment #4
karens commentedIn other words, I want the options to be :
1) First letter of full day name
2) First two letters of full day name (for countries where the first letter is the same)
3) Abbreviation, however it looks for each language
4) Full day name
I misspoke above about the core method, that is for month names, not day names. I'm not sure what core is doing about day name abbreviations. Can someone check?
Comment #5
panchoThanks Robert! Català seems to be the perfect use case for this, as in this sense it is the most tricky case! If Català works, all other languages should work as well... :)
My patch however should fix most problems for Català as well: You can translate both "Mon" and "Mo" to "Dll", and both "Sam" and "Sa" to "Ds".
1-letter-abbreviations I fear can be fixed only using some kind of trick: We could use "S|M|T|W|T|F|S" and translate this to "Dmg|Dll|Dmt|Dmc|Dj|Dv|Ds" (In Catalan), "D|L|M|M|J|V|S" (in French) or "S|M|D|M|D|F|S" (in German). Later we can explode it at the pipe ("|") borders.
If we really need to support 1-letter-abbreviations, we can't make sure they are really 1 letter long (because seven "D's" wouldn't make any sense in Català, neither would three "Dm's"). As their translated length ist completely unpredictable for the implementer of DateAPI, I would completely stop supporting 1-letter abbreviations and only offer 2-letter and 3-letter abbreviations. But if we say it is okay to offer functionality in an API that doesn't work well for some languages, then we can do the piped string trick.
Did I get Karen right, that we don't need to support abbreviations with more than 3 letters, e.g. "Mond" or "Monda". Actually I agree they make no sense, but I didn't want to rule them out. But finally they really don't seem to make sense in any language or context... :)
Finally: I will update the patch as soon as we reconsidered this and decided which route to go.
Comment #6
karens commentedYou can't make assumptions about what order the days are in, they will change depending on the way the site is set up, and even if the traditional calendar display is to show Monday first in these countries, we support alternate first days, so doing something like a string of letters with pipes won't work.
My plan is that we do literal 'First letter' and 'Second letter' options for all languages so they are available where they make sense. Those options would be exactly what they say, the first and first two letters of the name. Where they don't make sense, you wouldn't use them. In the USA, one-letter abbreviations are used a lot and are nice for tiny little calendars. In some languages you can't use the one-letter abbreviations, so we have the option for two letters. Where neither of these work, we will have an option for the regular abbreviation, whatever that is. Each calendar can use whatever works best for their situation.
In other words, I don't assume that all of these options will make sense for all languages, but the options will be there for the times when they do. So the only things to be translated would be the abbreviation and the full name. The one and two letter options will be created automatically from those strings.
Comment #7
robertgarrigos commentedI think it makes sense to have a one and two first letters options for the countries that would use them. A third option for a custom abbreviation would be then helpful for other countries.
Comment #8
panchoI see what you mean.
There is a problem though: implementations of the Date API often (including date_popup !) won't offer the webmaster a choice how weekdays are abbreviated. It's not the people of a certain country (or language) that can decide on which kind of abbreviation is used in a certain context, but it is the developers of a certain module implementing the Date API.
So my idea was to make sure translators and/or webmasters always have the final choice to make Date API implementations work in a certain language.
Second off, I certainly don't make any assumption about what order the days are in. The weekday order in the piped string does not predetermine the final display order. When Date API reads the string into an array, we have the matching translated abbreviations for every weekday. Then we still can manipulate the array to start with Sunday, Monday or whatever. So I'm very sure about that this way does work well.
Finally I'm still convinced that leaving the translation of 1-letter, 2-letter and 3-letter abbreviations independently to the translators instead of stripping some already translated string is the right way to go. Without predetermining the result of this discussion, I might write a new patch tonight to demonstrate you how it would work.
Localizing dates is obviously a very complex thing - see the neverending discussion about daylight saving time... :)
Comment #9
karens commentedAs the module author I can see no way that you could create a piped array of day names where the code would have any idea what value to use. When you're translating an individual day name the translation function will look for a translation for exactly the string you input, if you input the whole list, how will it know which value to pull out? It just won't work. We need a separate translation for each day and day abbreviation.
The only place 1 and 2 letter shortcuts are used is for calendar day headings, and you can select if you want to use that in the calendar settings, everywhere else we use the regular day abbreviation. So I repeat that I see no need to 'fix' the way of handling first and first two letter abbreviations. The calendar settings explicitly say that this is what they are, so if they don't make sense the admin would have no reason to select them. And they're not used anywhere else.
But please see that we already have a thread about creating a new method of localizing date formats and we now have this discussion duplicated in too many different threads.
I agree we need a different way of doing the weekday abbreviation translation, so we need a fix for that specific situation. I'm assuming core already has a way of doing this, and I asked above for someone to find out how that is done. If core is not doing that, we should use something like the core method of handling month full names and abbreviations for the day abbreviation. That makes the abbreviations translatable and appropriate for the language.
Comment #10
geraldito commentedDidn't find out the way core handles this case but I'm using the following workaround: I changed default value of $length=-1 in function 'date_week_days_abbr' and then take A. translated abbreviations if $length has default value or B. substring abbreviations if function is called with defined length. So module authors can decide which way to go for each case the design on calling this function with or without length parameter.
Comment #11
haggai_e commentedJust wanted to contribute my 2 cents about Hebrew. (Since I tried date_popup today and found out it can't currently be used).
In Hebrew, similar to what robertgarrigos said about Catalan, using the first letter of the translated makes no since, because 4 of the weekdays begin with the same letter. There is however a 1 letter abbreviation that is commonly used, where the days Sunday to Friday are abbreviated by the beginning letters of the alphabet, and Saturday is abbreviated with its first letter.
In addition, 3 or 2 letter abbreviations are never used.
Therefore, I think that Pancho's suggestion of letting the translators decide how to translate each of the abbreviations independently can work well for Hebrew, as we could just translate all 2 and 3 letter abbreviations to their 1 letter counterpart.
Comment #12
karens commentedChanging the title a bit, also we need to find a fix for translating 'second' that doesn't get confuse 'second' as a date part with 'second' as the order of things that happen.
Comment #13
hass commentedJoining :-). #347666: "Second" produces translatable string collision with panels module has been marked as a duplicate of this issue.
Comment #14
karens commentedOne more issue, 'Repeats' is used as a menu label for tabs and also in the description of how often a date repeats, and we need to differentiate those cases. Plus the handling of a description parsed out of the RRULE values is generally hard to translate and needs some re-thought.
Comment #15
karens commentedI'm playing around with some of the things suggested in #334283: Add msgctxt-type context to t() to see if I can create a system to handle our short string problems.
Although I originally dismissed the idea of providing a pipe-delimited string of the abbreviations, I now have an idea on how that might work as another option. I could create long, pipe-delimited strings for each set of abbreviations which could be translated and then instead of wrapping the abbreviations themselves in t(), I could create a custom function that would explode the values to grab the right substring out of that long translated string. I have to see if I can actually get this to work, but I think it has potential. And apologies to Pancho if that's what he meant all along and I was just not understanding.
Comment #16
karens commentedHere's what I'm planning to use. Can someone try this out and make sure you are able to translate those strings and get them to work in date_format_date(). There are other places in the code that I will use this, but I want to see if the basic system looks like it is working, so this patch just uses the new translation strings in date_format_date().
Comment #17
karens commentedI did some more work to this (some of the logic wasn't quite right, cleaned up some strings) and I think it works pretty well. It should be a big win for translators because it not only gives you good context for the strings, it also greatly reduces the number of strings that need to be translated. Instead of a string for every variant of 'Year' and 'Month', and 'Day', a single string with all of them.
I'm committing changes to Date and Calendar. The .pot files will need to be updated, but I will hold off on that until I find a fix for the other issues (if I can find one). But this takes care of all the problems of handling abbreviations.
Comment #18
karens commentedThe main remaining translation issue was the problem translating the repeating date description. I reworked the strings to combine the smaller parts into longer, more meaningful, strings and tried to add more context to the strings. I realize that there will be languages which need a completely different word construction where this still won't work right, but I think it is flexible enough now to work in many languages. When we find languages where it doesn't work you can post an issue with the specifics of what you get vs what you should be getting so we can further tweak the code.
I've committed some more fixes, tried creating new .pot files to see how things look there, and I think it is working well enough that I will mark this fixed.
Next I'll try to create new .pot files (I already see that creates some error messages I need to address) but that is another issue.
Comment #20
emok commentedAs I use the date_php4-module, I think I've found a few minor bugs introduced with the new translation system.
But the first part of my patch, that deals with date_api.module, looks like it is independent of PHP-version. It should even appear if your site is in English:
t($c)will evaluate tot('e')ort('T'), so you just see an "e" character in formats that should print the timezone name or "T" instead of the abbreviation. At least I saw the 'e' in my translated strings.In date_php4.inc, translated versions of day names were returned, which causes the new outer layer for translation to give empty strings. (I guess the old version passed the erroneously translated values through so you did not notice that they were translated at a too early stage.) The
$c == 'D'case indate_format()has not really been tested, sincedate_format_date()uses its own wrapping to handle translation of that case.There were also two lines where
$datewas used instead of$date_stringfor the output.It would be nice if someone on PHP5 could confirm that the patch does not break anything.
Oh, and the diff is rolled against the dev tarball of 2009-Mar-09. I named the file after the current date, which may be confusing.
Comment #21
karens commented@emok, you are so good at finding these little problems :) In testing this I found a couple other small fixes needed to display timezone names correctly. Fix applied to both the D5 and D6 versions.
Comment #23
Danic commentedI just downloaded your Date module and have the same issue. I live in germany and it has to be Mo, Di, Mi, Do, Fr, Sa, So. Instead its Mon-Son. What must I do, I followed the discussion here, but I could not see any workaround. I am using PHP version 5.2.0
Comment #24
robertgarrigos commentedYes, I'm having this again. The calendar block prints only the first letter of the day, even the translated string contains two letters for each day. am I missing something?
Comment #25
karens commentedPlease don't re-open a two year old issue for a newly discovered problem. If you are seeing a problem that is new or which seems to have re-surfaced ('I am seeing this again'), open a new issue with details about how to reproduce the problem.
Comment #26
karens commentedBTW, things like whether the calendar block uses the first letter or two letters or three is controlled in the calendar style settings for the calendar view -- a calendar issue.