Why is LOCALE_SDURATION so dorky-looking?


For formatting time spans, you can use the LOCALE_SDURATION format string, but the result is a dorky hh:mm:ss.ffff format. Why isn't there a LOCALE_SLONG­DURATION format that is fancier like hh hours, mm minutes, and ss.ffff seconds?

You have the complexities of natural language to thank.

In the general case, there is not enough information to provide the appropriate grammatical context in order to know the correct format. This isn't a big deal in English, since English words typically do not inflect for case (pronouns and genetive being the most commonly-encountered exceptions), but in many other languages, choosing the exact form of the word "hours" depends on grammatical information that cannot be captured in a simple call to Get­Locale­Info.

For example, if you wanted to say "Last modified hh hours, mm minutes, and ss.ffff seconds ago", the word "hours" would need one form, whereas if you had wanted to say "Active for hh hours, mm minutes, and ss.ffff seconds", the word "hours" would need a different form. Some languages have quite a large number of grammatical cases (I'm looking at you, Finnish), and expressing all of this programmatically in a uniform way across all languages is impractical. The preposition since might take the accusative case in one language, but the genitive in another.¹

And we haven't even gotten into the crazy world of singular/plural/dual/paucal, or whether zero is singular or plural.

The language folks may have realized that they didn't want to dig themselves into a hole like they did with genitive months.

¹ And then there's German, where some prepositions take multiple cases depending on context. Consider, for example, the preposition unter, meaning under.

Sentence Case Translation Context
Wir laufen unter die Brücke. Accusative We run under the bridge. We start outside the bridge, go under it, then go out the other side stay underneath. [Thanks to Piotr and Axel for the correction.] (The path takes us under a bridge.)
Wir laufen unter der Brücke. Dative We run under the bridge. We stay under the bridge the whole time. (It's raining, so we are doing our running exercise under a bridge in order to stay dry.)

I've internalized the rule for deciding which case to use, so much so that it's hard for me to explain it, but I'll try anyway. If the preposition applies throughout the entire activity, you use the dative. But if the point of the sentence is that situation changed from "not applicable" to "applicable" (in our example, from "not under" to "under"), then use the accusative. This is usually described in grammar books as change of position or motion toward a goal.

Comments (31)
  1. Uli Gerhardt says:

    Maybe the rule is easier to see with "in": "I walk into the house." = "Ich gehe in das Haus." = accusative vs. "I walk in(side) the house." = "Ich gehe im Haus." = dative.

  2. ZOMFGZORZ says:

    These are perfect examples of why German is a horrible language.

  3. Piotr says:

    German here, nitpicking as usual. "Wir laufen unter die Brücke" implies that we stay under the bridge – for example, because it's raining. If you're describing a path that takes you under a bridge, you'd rather say "Wir laufen unter der Brücke hindurch.". Please, don't ask why we're back to Dative.

    Another complication regarding the cases in German that there's (as usual) a few special cases – words which just demand a specific case. There's currently also a change in spoken German in towards favoring the dative over genitive and accusative.

    [Thanks for the correction. I never learned the hindurch version. And yes, there are the prepositions which take the same case regardless of whether there is a change of location. Curiously, "in" (in/inside) is a context-sensitive preposition but the corresponding "aus/außer" (out/outside) always takes dative. That's just the way it is. Don't fight it; revel in it. -Raymond]
  4. Uli Gerhardt says:

    @ZOMFGZORZ: These are perfect examples of why German is a beautiful and expressive language. :-)

    [Exactly. It shows how variations in meaning can be encoded compactly. -Raymond]
  5. Axel says:

    Actually "Wir laufen unter die Brücke" means that you go under the bridge and stay there. If you would go out of the other side you would say "Wir laufen unter der Brücke durch".

  6. Ken Hagan says:

    I've just googled for "paucal" and consumed the wikipedia article on Grammatical Number. As a result, I no longer believe that it is possible to translate from one language to another. It doesn't even make sense to try. The only feasible approach is to kill yourself, hoping to be re-incarnated as someone else and have sufficiently similar life experiences that (by chance) you happen to want to express the same mental processes. Any other approach is just naive.

  7. Ken Hagan says:

    @ZOMFGZORZ: If you're bothered by that rule in German, please don't read the wikipedia article on Grammatical Number. It might kill you.

  8. Jim says:

    @Ken Hagan Bravo, you just pointed out the general problems of translation. The original meanings are all lost during the process..

  9. Evan says:

    "'People called Romanis they go the outs'?!"

    "It says, 'Romans go home.'"

    "No it doesn't."

  10. Alex Cohn says:

    Some people believe that it's enough to set locale, and the OS will take care of all dates' rendering. Luckily, there is a lot of custom coding to do, so that it looks natural in many languages. Multilingual is a never-draining source of programmers' income.

  11. @Evans says:

    no, it's "people called romanes, they go, the house?"

    Funnily, that scene had Brian mention both dative and accusative, but the Centurion pointed out that the correct case is Locative.

    English has it easy.

  12. > whether zero is singular or plural

    As far as I can see, zero is plural. Is there a case where zero is (or could be) singular?

  13. alegr1 says:

    > Is there a case where zero is (or could be) singular?

    A zero point of the axis.

    On the axis the zero is here

  14. Adam Rosenfield says:

    @Maurits: I don't speak Arabic, but according to Google's localization documentation for Android (developer.android.com/…/string-resource.html), Arabic has special handling for when you have zero of something.

  15. j b says:

    @Maurits: As far as I can see, zero is plural. Is there a case where zero is (or could be) singular?

    Norwegian is similar, as long as you use the _numeral_ zero – but I certainly wouldn't bet on this being true in all languages.

    And: Several word equivalents to zero are singular, at least in Norwegian. "There is no ball here" – but "There are 0 balls here". (There are several Norwegian words expressing "no" or "zero").

    In old Norwegian (/Norse), you had not only singular and plural, but "dual" (I don't know the linguist term for that) – a special form when there are two of something. Some old dialects had special forms for three and even four. That is several hundred years ago, but I wouldn't be surprised if other languages have similar pecularities. You may consider it old remains of a "dual" form in English that "He is the older of my sons" indicates that you have two sons, but "He is the oldest of my sons" indicates that you have three or more sons.

  16. j b says:

    @ZOMFGZORZ: These are perfect examples of why German is a horrible language.

    Often (in particular in languages like Finish, not as pronounced in German) cases more or less replace prepositions. Prepositions are Headache #1 when translating between modern Western languages. The easiest way to spot a non-native speaker of e.g. Norwegian (e.g. a Swede with perfect Norwegian pronounciation) is by incorrect choice of prepositions. My Finish work fellows claim that the problem is practically non-existing when translating to Finish: The semantics umambigously implies a case; in most cases there is no supplementary word (i.e. a preposition) that cold have been chosen incorrectly.

    In Western languages, sometimes it doesn't even require a translation for prepositions to cause problems: I once caused a real dogfight between three of my work mates, one British, one Australian and one American. I asked the Brit for the right preposition to use in a sentence, and she gave her proposal. This was overheard by the two others, who rose from their desks and came over to "correct" her, each with their own, very firm ideas about the preposition to use. All three were so determined that no other than their own prosal was acceptable that they kept on arguing this loudly, standig up and refusing to go sit down at their desks, for the rest of the working day…

  17. Joshua Ganes says:

    @j b – I'm intrigued. Can you elaborate on the phrase you were composing and the prepositions proposed by the speakers from each country?

  18. Evan says:

    > "no, it's 'people called romanes, they go, the house?'"

    That makes more sense. I could never quite tell what Cleese was saying, and "the outs" (as in, "leave") seemed like the most accurate interpretation.

    It was that clip, I think, that made me first realize how "complicated" other languages could be from the standpoint of a native English speaker who had only had a little bit of Spanish. (Also I think I may have learned as much formal linguistics stuff that applies to English from my Spanish classes as I did from English classes through school. :-) For example, both languages have a subjunctive sense, but I don't think I ever learned about it explicitly or under that term in English class.)

  19. alegr1 says:

    @j b:

    >This was overheard by the two others, who rose from their desks and came over to "correct" her, each with their own, very firm ideas about the preposition to use.

    If you manipulate segments and page tables, you can use all three preposisions at once, don't worry.

  20. not important says:

    Jim and Ken Kagan – there is a way to translate a phrase from one language to another. Just look for the how phrase was translated already:). To translate from English to Spanish, look for the phrase in a book written by Shakespeare which is translated in Spanish. Or in some EU treaty / regulation (these must be translated in, I don't know, 20-something languages). And now you have a translation :)

  21. @ @evans : "English has it easy"

    This is at least one theory I heard relatively recently, attempting to explain the "success" of English as an international language.  Not because of some consequence of globe encompassing colonial imposition of the language, or because English speakers are too lazy to learn other people's languages, but simply because the "flexibility" of English makes it ideally suited as a common language to mediate between any number of other languages that are far more sensitive to mis-translation.

  22. Miff says:

    I always believed the reason English got so successful is that since we popularized the computer, we got to invent ASCII and practically lock out every other language's alphabet until Unicode was invented and gained popularity.

  23. Mike Dimmick says:

    @Maurits: zero is singular in French.

    We got our information on Grammatical Numbers from doc.qt.digia.com/…/qq19-plurals.html . Correctly handling grammar when gluing bits of string together certainly looks better, but it causes one hell of a lot of extra work. The cop-out, an uninflected label that covers most cases, e.g. 'Items: 1', is far, far easier than trying to teach your computer how to speak a dozen different languages.

    [Chinese has a bonus tricky, because there is a special word for two (兩) which is used when you are saying the number of items, as opposed to the concept of the number two or the symbol "2" (e.g. reciting a phone number). I doubt any programs bother taking this into account. -Raymond]
  24. alegr1 says:

    >Chinese has a bonus tricky, because there is a special word for two which is used when you are saying the number of items

    I wonder is there is a couple such words in English, or pair of.

    [Indeed, English has similar concepts, but whereas in English its use is optional (both "two dogs" and "a pair of dogs" are acceptable), in Chinese the use of the special form is mandatory. -Raymond]
  25. Mihai says:

    @Mike Dimmick

    "We got our information on Grammatical Numbers from doc.qt.digia.com/…/qq19-plurals.html"

    If the library implements the rules as listed on that page (only for those locales), then it is incomplete.

    A more complete list is available as part of CLDR (http://cldr.unicode.org/), in the common/supplemental/plurals.xml file.

    And relatively easy to use with ICU4J or ICU4C.

  26. Mihai says:

    Added complexities:

    – The plural forms for hours/minutes/seconds would have to be resolved independently

    – Plural forms for fractional values (if you want to support something like "3.5 hours")

    Languages are hard, let's all speak English :-)

    Although I can tell you: as a non-native speaker, English is not that simple either.

    The worst part is the unpredictible spelling system.

    Change it something like Italian (write it as you say it) and you have a real winner :-)

    But I know it will not happen :-)

  27. Miles says:

    Raymond – I had the complete same understanding of how to use die/der Bruecke as you, I'm super surprised (and still a bit confused) about the actual use.

  28. Pseudo-Anonymous says:

    @Mihal: How exactly would you change all the words in English so that they can be spelled phonetically?

  29. <<How exactly would you change all the words in English so that they can be spelled phonetically?>>

    That will never happen. Unfortunately, the English spelling is a dinosaur, although hardly any native speaker is aware of the fact tbat they are writing the way the language was spoken around the London court even long before Shakespeare. It doesn't make it any better when using English as the universal computer language given those restrictions, but somehow everyone got used to the fact.

    Rüdiger

  30. j b says:

    @Mihai, Pseudo-Anonymous, …

    I guess quite a few of you know "The Chaos" or "English is tough stuff". It is available dozens of places on the Internet – the first one I came across right now was

    pauillac.inria.fr/…/english-pronunciation.html

    The whole point is in reading it out loud – AND keeping an eye on the spelling as you read it. It is supposed to rhyme all the way through, in spite of the spelling.

    There are lots of rumours associated with the this verse, such as its origin being in some NATO headquarters, the author being unknown etc. The author IS known, Gerald Nolst Trenite, and it was published long before NATO was conceived – around 1930. Whatever the truth or falsity of the rumours: The poem is both fun and challenging.

  31. Engywuck says:

    and then you have to think about differences of the same language in different regions. I would have translated "laufen" with "walk", but I'm from southern germany. Northern germay use would indeed be "run".

Comments are closed.