Page 1 of 3 123 LastLast
Results 1 to 10 of 23

Thread: Universal ordinal numbers.

  1. #1
    Join Date
    Sep 2007
    Location
    Christchurch, New Zealand
    Beans
    1,328
    Distro
    Ubuntu

    Universal ordinal numbers.

    Ordinal means 1st, 2nd, 3rd...

    Programmers hard code such suffixes in their software. However why do it over and over, in every application, and did you consider exceptions like 11th instead of 11st?

    Then when you come to internationalize your software, notice what a nightmare! All that logic you put in... she only applies to English!

    Now I think I have formula to make it universal and available to ALL applications and I want YOUR opinions, like whould it be useful and what have I missed?

    So my proposal is to use the standard gettext internationalization and localization practices to solve this for English as well as every other languages on our planet

    Start with my demo application. Intention is that EVERY app that needs ordinals in ANY language can use this same standard dngettext as follows:

    Code:
    // g++ youcame.c
    #include <stdio.h>
    #include <libintl.h>
    #include <locale.h>
    
    int main(int argc, char **argv) {
    	setlocale( LC_ALL, "" );
    	for (int i = 1; i < 25; ++i) printf(
    		gettext("In the human race you came %d%s today!\n"),
    		i, dngettext("_ordinal", "°","°", i)
    	);
    	return 0;
    }
    Summary of proposed conventions
    -------------------------------

    1. In source code (C domain) ordinals implemented with the text string "°" and translated with dngettext().

    2. Each language (yes even English) to have it's own _ordinal.po file. Let me know if you have problems installing this localization:

    # English "translations" for _ordinal package.
    # Copyright (C) 2010 public domain
    #
    msgid ""
    msgstr ""
    "Project-Id-Version: 1\n"
    "Report-Msgid-Bugs-To: \n"
    "POT-Creation-Date: 2010-08-09 14:00+1200\n"
    "PO-Revision-Date: 2010-08-09 14:15+1200\n"
    "Last-Translator: chris scaife <scaife.chris@gmail.com>\n"
    "Language-Team: English\n"
    "MIME-Version: 1.0\n"
    "Content-Type: text/plain; charset=UTF-8\n"
    "Content-Transfer-Encoding: 8bit\n"
    "Plural-Forms: nplurals=4; plural=(n+9)%10<3 && (n+90)%100>10 ? (n+9)%10 : 3;\n"


    #: English ordinal numbers
    msgid "°"
    msgid_plural "°"
    msgstr[0] "st"
    msgstr[1] "nd"
    msgstr[2] "rd"
    msgstr[3] "th"

    Observations
    -----------

    - Using the ordinal character ° as standard in C domain aims to
    discourage programmed localization for English.

    - I prepend underscore on _ordinal domain because it is general
    purpose and not want it conflicting with othere packages

  2. #2
    Join Date
    Apr 2007
    Location
    NorCal
    Beans
    1,149
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Universal ordinal numbers.

    Code:
    CL-USER> (format t "~:r" 1234)
    one thousand two hundred thirty-fourth


    Might I suggest using a character that appears on most standard keyboards? I'd hate to have to have a keyboard palette out all the time while coding...
    Posting code? Use the [code] or [php] tags.
    I don't care, I'm still free. You can't take the sky from me.

  3. #3
    Join Date
    Sep 2007
    Location
    Christchurch, New Zealand
    Beans
    1,328
    Distro
    Ubuntu

    Re: Universal ordinal numbers.

    Thanks for reply Schaurelich

    I don't recognise that format command, but find myself wondering none the less how it would perform for say a French person who has sellect the French language on their computer.

    Now I did think exactly same as you about using a key more commonly found on standard keyboard and following considerations came to mind:

    • "Standard" keyboard is different in each country.
    • The meaning still has to be intelligible in default POSIX/C locale.
    • ordinal ° is Alt+Shift+; when I select USA-international layout for my keyboard.
    • It is unlikely to be used so frequently that getting it from Character Map would be a major inconvenience.
    • Discourage hard coded localization for English.
    • Encourage use of internationalization package.
    • Avoid conflict translating characters not intended to represent ordinals.


    So you see I did think it through and thus I really appreciate the feedback

    Now translating ordinals to some languages like Italian introduce the complication of gender: 1st woman is 1ª and first man is 1º. I'm still thinking about how to make it truly internationalizable... I just wish I knew more about ordinals in non-western locales and hoping someone who does reads these Ubuntu forums
    Last edited by worksofcraft; August 11th, 2010 at 12:40 AM. Reason: add avoiding conflict consideration

  4. #4
    Join Date
    Apr 2007
    Location
    NorCal
    Beans
    1,149
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Universal ordinal numbers.

    Quote Originally Posted by worksofcraft View Post
    Thanks for reply Schaurelich

    I don't recognise that format command, but find myself wondering none the less how it would perform for say a French person who has sellect the French language on their computer.
    It's a nifty function from Common Lisp. It's basically its own embedded language... think printf on steroids. I'm guessing there's implementation-dependent localization options available, but I have no idea.

    Now I did think exactly same as you about using a key more commonly found on standard keyboard and following considerations came to mind:
    Still, don't you think it's more convenient to use a symbol that you know will be on a keyboard of someone programming in C? perhaps * for its visual resemblance to º? Since it's quoted it shouldn't matter.
    Posting code? Use the [code] or [php] tags.
    I don't care, I'm still free. You can't take the sky from me.

  5. #5
    Join Date
    Sep 2007
    Location
    Christchurch, New Zealand
    Beans
    1,328
    Distro
    Ubuntu

    Re: Universal ordinal numbers.

    Yeah I know, as an English speaking programmer myself it is very hard to understand problems faced by ordinary users in far away exotic places.

    Now you see if I have NO locale defined all my software runs with the default POSIX locale and output of my sample program looks like this:

    Code:
    $> unset LANG
    $> ./a.out
    In the human race you come 1° today
    In the human race you come 2° today
    In the human race you come 3° today
    ...
    Not exactly perfect for us English speakers.
    Thus I reinstate my normal Kiwi English locale. The output now becomes exactly what I want and I would like ALL my applications to be able to behave just as nicely for EVERYONE on our planet

    Code:
    $ export LANG=en_NZ.UTF-8
    $ ./a.out
    In the human race you come 1st today
    In the human race you come 2nd today
    In the human race you come 3rd today
    ...
    I don't know... perhaps I just lost that human race but I do hope I haven't lost "the game" yet

  6. #6
    Join Date
    Sep 2007
    Location
    Christchurch, New Zealand
    Beans
    1,328
    Distro
    Ubuntu

    Re: Universal ordinal numbers.

    Now if I change my demo to say

    Today she came 3rd in the human race

    and select the Italian locale I want it to say

    Oggi è venuta 3ª nella razza umana

    Well actually race has two translations: razza and corsa because the English pun doesn't work in Italiano... but that's not really the issue.

    So my solution is to add the following to my _ordinal.po portable object for English locale. This way the programmer is at liberty to choose whether it is the order of feminine entities and then it translates just fine for English languages that have no gender distinction on ordinals as well as for the ones that do. However perhaps I'm jumping the gun a bit here!!

    Code:
    #: feminine ordinal numbers
    msgid "ª"
    msgid_plural "ª"
    msgstr[0] "st"
    msgstr[1] "nd"
    msgstr[2] "rd"
    msgstr[3] "th"
    p.s. It may not be very legible there but that's the feminine ordinal symbol, a little superscripted "a". Note, now you can see I wouldn't want to translate our regular "a" into "st", "nd", "rd" or "th" because "a" has legitimate meaning already on it's own.
    Last edited by worksofcraft; August 11th, 2010 at 01:05 AM.

  7. #7
    Join Date
    Jul 2006
    Location
    somewhere :)
    Beans
    535
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Universal ordinal numbers.

    in a number of languages you have the problem that ordinal numbers decline. this would make the task even more convoluted.
    there are 10 types of people in the world: those that understand binary and i don't know who the other F are.

  8. #8
    Join Date
    Sep 2007
    Location
    Christchurch, New Zealand
    Beans
    1,328
    Distro
    Ubuntu

    Re: Universal ordinal numbers.

    Hum... yes I googled that. Russian seems to be a test case example, so I suppose my real question is what would Russians expect from their computers?

    According to www.freetranslation.com

    "She came 2nd in the human race today"
    would become: "она приехала 2-ая в человеческий род сегодня!"
    While "he came 2nd in the human race today!"
    reads as "он приехал 2-ой в человеческий род сегодня!"

    So would they be happy enough if in general 2º translates to "2-ой" and 2ª to "2-ая"? While with three it becomes "3-ий" and "3-ья" and so on? Just how on Earth do their computer programmers cope at the moment for this kinda stuff I wonder :O

  9. #9
    Join Date
    Sep 2007
    Location
    Christchurch, New Zealand
    Beans
    1,328
    Distro
    Ubuntu

    Re: Universal ordinal numbers.

    Anyway so I'm making a virtual appliance, specifically for developing internationalization of software. It includes my internationalization tutorial materials I'm working on.

    Also has logins each with different locale. To keep it all compact I'm assuming every virtual user can work with English development tools.

    If anyone else interested in this I could post my virtual appliance somewhere perhaps. Atm it just has en_NZ and it_IT locales but I do hope to add to it, or perhaps people who understand different cultures might want to add theirs... IDK?!

  10. #10
    Join Date
    Jul 2006
    Location
    somewhere :)
    Beans
    535
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Universal ordinal numbers.

    Quote Originally Posted by worksofcraft View Post
    Hum... yes I googled that. Russian seems to be a test case example, so I suppose my real question is what would Russians expect from their computers?

    According to www.freetranslation.com

    "She came 2nd in the human race today"
    would become: "она приехала 2-ая в человеческий род сегодня!"
    While "he came 2nd in the human race today!"
    reads as "он приехал 2-ой в человеческий род сегодня!"

    So would they be happy enough if in general 2º translates to "2-ой" and 2ª to "2-ая"? While with three it becomes "3-ий" and "3-ья" and so on? Just how on Earth do their computer programmers cope at the moment for this kinda stuff I wonder :O
    declining is more than that. for example in german:

    the second star wars film was made in 1982
    der zweite (second, male nominative strongly declined) "krieg der sterne"-film wurde 1982 gedreht

    i saw the second star wars film last tuesday
    letzten dienstag habe ich den zweiten (second, male accusative strongly declined) "krieg der sterne"-film gesehen.

    no one ever tried it again
    ein zweiter (second, male nominative weakly declined) hat es nie versucht

    the second door on the left leads to the gym
    die zweite (second, female nominative strongly declined) tuer links fuehrt zum kraftraum

    take the second door on the left.
    nehmen sie die zweite (second, female accusative strongly declined) tuer links.

    second-hand clothes
    kleidung aus zweiter (second, female dative weakly declined) hand.


    etc. etc.

    you see, it's quite difficult.

    of course, in german you don't really have this problem because ordinal numbers can always be written 2. (for second) or in general n. (for nth). but i don't think this is the case for Russian or Polish or similar.
    there are 10 types of people in the world: those that understand binary and i don't know who the other F are.

Page 1 of 3 123 LastLast

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •