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
Bookmarks