# HG changeset patch # User rubidium # Date 1174342098 0 # Node ID d0fc5d926679a52420a2ca3446e8192a152e7c5d # Parent 9fce095970bb744e2d36c22c50a5a487cfcf4c0a (svn r9355) [0.5] -Backport from trunk (r8906): - Feature: translation dependant formatting of dates (r8906) diff -r 9fce095970bb -r d0fc5d926679 lang/american.txt --- a/lang/american.txt Mon Mar 19 21:42:05 2007 +0000 +++ b/lang/american.txt Mon Mar 19 22:08:18 2007 +0000 @@ -3135,6 +3135,9 @@ STR_MEASURE_AREA_HEIGHTDIFF :{BLACK}Area: {NUM} x {NUM}{}Height difference: {NUM} m ############ Date formatting +STR_DATE_TINY :{STRING}-{STRING}-{NUM} +STR_DATE_SHORT :{STRING} {NUM} +STR_DATE_LONG :{STRING} {STRING} {NUM} ######## diff -r 9fce095970bb -r d0fc5d926679 lang/brazilian_portuguese.txt --- a/lang/brazilian_portuguese.txt Mon Mar 19 21:42:05 2007 +0000 +++ b/lang/brazilian_portuguese.txt Mon Mar 19 22:08:18 2007 +0000 @@ -3138,6 +3138,9 @@ STR_MEASURE_AREA_HEIGHTDIFF :{BLACK}Area: {NUM} x {NUM}{}Diferença de altura: {NUM} m ############ Date formatting +STR_DATE_TINY :{STRING}-{STRING}-{NUM} +STR_DATE_SHORT :{STRING} {NUM} +STR_DATE_LONG :{STRING} {STRING} {NUM} ######## diff -r 9fce095970bb -r d0fc5d926679 lang/bulgarian.txt --- a/lang/bulgarian.txt Mon Mar 19 21:42:05 2007 +0000 +++ b/lang/bulgarian.txt Mon Mar 19 22:08:18 2007 +0000 @@ -3137,6 +3137,9 @@ STR_MEASURE_AREA_HEIGHTDIFF :{BLACK}Площ: {NUM} x {NUM}{}Разлика във височината: {NUM} м ############ Date formatting +STR_DATE_TINY :{STRING}-{STRING}-{NUM} +STR_DATE_SHORT :{STRING} {NUM} +STR_DATE_LONG :{STRING} {STRING} {NUM} ######## diff -r 9fce095970bb -r d0fc5d926679 lang/catalan.txt --- a/lang/catalan.txt Mon Mar 19 21:42:05 2007 +0000 +++ b/lang/catalan.txt Mon Mar 19 22:08:18 2007 +0000 @@ -3135,6 +3135,9 @@ STR_MEASURE_AREA_HEIGHTDIFF :{BLACK}Àrea: {NUM} x {NUM}{}Diferència d'alçada: {NUM} m ############ Date formatting +STR_DATE_TINY :{STRING}-{STRING}-{NUM} +STR_DATE_SHORT :{STRING} {NUM} +STR_DATE_LONG :{STRING} {STRING} {NUM} ######## diff -r 9fce095970bb -r d0fc5d926679 lang/czech.txt --- a/lang/czech.txt Mon Mar 19 21:42:05 2007 +0000 +++ b/lang/czech.txt Mon Mar 19 22:08:18 2007 +0000 @@ -3199,6 +3199,9 @@ STR_MEASURE_AREA_HEIGHTDIFF :{BLACK}Oblast: {NUM} x {NUM}{}Výškový rozdíl: {NUM} m ############ Date formatting +STR_DATE_TINY :{STRING}-{STRING}-{NUM} +STR_DATE_SHORT :{STRING} {NUM} +STR_DATE_LONG :{STRING} {STRING} {NUM} ######## diff -r 9fce095970bb -r d0fc5d926679 lang/danish.txt --- a/lang/danish.txt Mon Mar 19 21:42:05 2007 +0000 +++ b/lang/danish.txt Mon Mar 19 22:08:18 2007 +0000 @@ -3132,6 +3132,9 @@ STR_MEASURE_AREA_HEIGHTDIFF :{BLACK}Areal: {NUM} x {NUM}{}Højdeforskel: {NUM} m ############ Date formatting +STR_DATE_TINY :{STRING}-{STRING}-{NUM} +STR_DATE_SHORT :{STRING} {NUM} +STR_DATE_LONG :{STRING} {STRING} {NUM} ######## diff -r 9fce095970bb -r d0fc5d926679 lang/dutch.txt --- a/lang/dutch.txt Mon Mar 19 21:42:05 2007 +0000 +++ b/lang/dutch.txt Mon Mar 19 22:08:18 2007 +0000 @@ -3135,6 +3135,9 @@ STR_MEASURE_AREA_HEIGHTDIFF :{BLACK}Gebied: {NUM} x {NUM}{}Hoogte verschil: {NUM} m ############ Date formatting +STR_DATE_TINY :{STRING}-{STRING}-{NUM} +STR_DATE_SHORT :{STRING} {NUM} +STR_DATE_LONG :{STRING} {STRING} {NUM} ######## diff -r 9fce095970bb -r d0fc5d926679 lang/english.txt --- a/lang/english.txt Mon Mar 19 21:42:05 2007 +0000 +++ b/lang/english.txt Mon Mar 19 22:08:18 2007 +0000 @@ -3133,4 +3133,9 @@ STR_MEASURE_LENGTH_HEIGHTDIFF :{BLACK}Length: {NUM}{}Height difference: {NUM} m STR_MEASURE_AREA_HEIGHTDIFF :{BLACK}Area: {NUM} x {NUM}{}Height difference: {NUM} m +############ Date formatting +STR_DATE_TINY :{STRING}-{STRING}-{NUM} +STR_DATE_SHORT :{STRING} {NUM} +STR_DATE_LONG :{STRING} {STRING} {NUM} + ######## diff -r 9fce095970bb -r d0fc5d926679 lang/esperanto.txt --- a/lang/esperanto.txt Mon Mar 19 21:42:05 2007 +0000 +++ b/lang/esperanto.txt Mon Mar 19 22:08:18 2007 +0000 @@ -3134,6 +3134,9 @@ STR_MEASURE_AREA_HEIGHTDIFF :{BLACK}Regiono: {NUM} x {NUM}{}Altecdiferenco: {NUM} m ############ Date formatting +STR_DATE_TINY :{STRING}-{STRING}-{NUM} +STR_DATE_SHORT :{STRING} {NUM} +STR_DATE_LONG :{STRING} {STRING} {NUM} ######## diff -r 9fce095970bb -r d0fc5d926679 lang/finnish.txt --- a/lang/finnish.txt Mon Mar 19 21:42:05 2007 +0000 +++ b/lang/finnish.txt Mon Mar 19 22:08:18 2007 +0000 @@ -3129,6 +3129,9 @@ STR_MEASURE_AREA_HEIGHTDIFF :{BLACK}Pinta-ala: {NUM} x {NUM}{}Korkeusero: {NUM} m ############ Date formatting +STR_DATE_TINY :{STRING}-{STRING}-{NUM} +STR_DATE_SHORT :{STRING} {NUM} +STR_DATE_LONG :{STRING} {STRING} {NUM} ######## diff -r 9fce095970bb -r d0fc5d926679 lang/french.txt --- a/lang/french.txt Mon Mar 19 21:42:05 2007 +0000 +++ b/lang/french.txt Mon Mar 19 22:08:18 2007 +0000 @@ -3135,6 +3135,9 @@ STR_MEASURE_AREA_HEIGHTDIFF :{BLACK}Région: {NUM} x {NUM}{}Ecart d'altitude: {NUM} m ############ Date formatting +STR_DATE_TINY :{STRING}/{STRING}/{NUM} +STR_DATE_SHORT :{STRING} {NUM} +STR_DATE_LONG :{STRING} {STRING} {NUM} ######## diff -r 9fce095970bb -r d0fc5d926679 lang/german.txt --- a/lang/german.txt Mon Mar 19 21:42:05 2007 +0000 +++ b/lang/german.txt Mon Mar 19 22:08:18 2007 +0000 @@ -3134,6 +3134,9 @@ STR_MEASURE_AREA_HEIGHTDIFF :{BLACK}Gebiet: {NUM} x {NUM}{}Höhenunterschied: {NUM} m ############ Date formatting +STR_DATE_TINY :{STRING}-{STRING}-{NUM} +STR_DATE_SHORT :{STRING} {NUM} +STR_DATE_LONG :{STRING} {STRING} {NUM} ######## diff -r 9fce095970bb -r d0fc5d926679 lang/hungarian.txt --- a/lang/hungarian.txt Mon Mar 19 21:42:05 2007 +0000 +++ b/lang/hungarian.txt Mon Mar 19 22:08:18 2007 +0000 @@ -3237,6 +3237,9 @@ STR_MEASURE_AREA_HEIGHTDIFF :{BLACK}Terület: {NUM} x {NUM}{}Magasságkülönbség: {NUM} m ############ Date formatting +STR_DATE_TINY :{STRING}-{STRING}-{NUM} +STR_DATE_SHORT :{STRING} {NUM} +STR_DATE_LONG :{STRING} {STRING} {NUM} ######## diff -r 9fce095970bb -r d0fc5d926679 lang/italian.txt --- a/lang/italian.txt Mon Mar 19 21:42:05 2007 +0000 +++ b/lang/italian.txt Mon Mar 19 22:08:18 2007 +0000 @@ -3134,6 +3134,9 @@ STR_MEASURE_AREA_HEIGHTDIFF :{BLACK}Area: {NUM} x {NUM}{}Differenza in altezza: {NUM} m ############ Date formatting +STR_DATE_TINY :{STRING}-{STRING}-{NUM} +STR_DATE_SHORT :{STRING} {NUM} +STR_DATE_LONG :{STRING} {STRING} {NUM} ######## diff -r 9fce095970bb -r d0fc5d926679 lang/japanese.txt --- a/lang/japanese.txt Mon Mar 19 21:42:05 2007 +0000 +++ b/lang/japanese.txt Mon Mar 19 22:08:18 2007 +0000 @@ -3135,6 +3135,9 @@ STR_MEASURE_AREA_HEIGHTDIFF :{BLACK}地域:{NUM} x {NUM}{}高さの違い:{NUM} m ############ Date formatting +STR_DATE_TINY :{2:NUM}-{1:STRING}-{0:STRING} +STR_DATE_SHORT :{1:NUM}年{0:STRING} +STR_DATE_LONG :{2:NUM}年{1:STRING}{0:STRING} ######## diff -r 9fce095970bb -r d0fc5d926679 lang/korean.txt --- a/lang/korean.txt Mon Mar 19 21:42:05 2007 +0000 +++ b/lang/korean.txt Mon Mar 19 22:08:18 2007 +0000 @@ -3136,6 +3136,9 @@ STR_MEASURE_AREA_HEIGHTDIFF :{BLACK}넓이: {NUM} x {NUM}{}고도차: {NUM} m ############ Date formatting +STR_DATE_TINY :{STRING}-{STRING}-{NUM} +STR_DATE_SHORT :{STRING} {NUM} +STR_DATE_LONG :{STRING} {STRING} {NUM} ######## diff -r 9fce095970bb -r d0fc5d926679 lang/norwegian_bokmal.txt --- a/lang/norwegian_bokmal.txt Mon Mar 19 21:42:05 2007 +0000 +++ b/lang/norwegian_bokmal.txt Mon Mar 19 22:08:18 2007 +0000 @@ -3129,6 +3129,9 @@ STR_MEASURE_AREA_HEIGHTDIFF :{BLACK}Område: {NUM} x {NUM}{}Høydeforskjell: {NUM} m ############ Date formatting +STR_DATE_TINY :{STRING}-{STRING}-{NUM} +STR_DATE_SHORT :{STRING} {NUM} +STR_DATE_LONG :{STRING} {STRING} {NUM} ######## diff -r 9fce095970bb -r d0fc5d926679 lang/norwegian_nynorsk.txt --- a/lang/norwegian_nynorsk.txt Mon Mar 19 21:42:05 2007 +0000 +++ b/lang/norwegian_nynorsk.txt Mon Mar 19 22:08:18 2007 +0000 @@ -3135,6 +3135,9 @@ STR_MEASURE_AREA_HEIGHTDIFF :{BLACK}Område: {NUM} x {NUM}{}Høgdeskilnad: {NUM} m ############ Date formatting +STR_DATE_TINY :{STRING}-{STRING}-{NUM} +STR_DATE_SHORT :{STRING} {NUM} +STR_DATE_LONG :{STRING} {STRING} {NUM} ######## diff -r 9fce095970bb -r d0fc5d926679 lang/polish.txt --- a/lang/polish.txt Mon Mar 19 21:42:05 2007 +0000 +++ b/lang/polish.txt Mon Mar 19 22:08:18 2007 +0000 @@ -3263,6 +3263,9 @@ STR_MEASURE_AREA_HEIGHTDIFF :{BLACK}Obszar: {NUM} x {NUM}{}Różnica wysokości: {NUM} m ############ Date formatting +STR_DATE_TINY :{STRING}-{STRING}-{NUM} +STR_DATE_SHORT :{STRING} {NUM} +STR_DATE_LONG :{STRING} {STRING} {NUM} ######## diff -r 9fce095970bb -r d0fc5d926679 lang/portuguese.txt --- a/lang/portuguese.txt Mon Mar 19 21:42:05 2007 +0000 +++ b/lang/portuguese.txt Mon Mar 19 22:08:18 2007 +0000 @@ -3132,6 +3132,9 @@ STR_MEASURE_AREA_HEIGHTDIFF :{BLACK}Área: {NUM} x {NUM}{}Diferença de altura: {NUM} m ############ Date formatting +STR_DATE_TINY :{STRING}-{STRING}-{NUM} +STR_DATE_SHORT :{STRING} {NUM} +STR_DATE_LONG :{STRING} {STRING} {NUM} ######## diff -r 9fce095970bb -r d0fc5d926679 lang/romanian.txt --- a/lang/romanian.txt Mon Mar 19 21:42:05 2007 +0000 +++ b/lang/romanian.txt Mon Mar 19 22:08:18 2007 +0000 @@ -3132,6 +3132,9 @@ STR_MEASURE_AREA_HEIGHTDIFF :{BLACK}Suprafata: {NUM} x {NUM}{}Diferenta inaltime: {NUM} m ############ Date formatting +STR_DATE_TINY :{STRING}-{STRING}-{NUM} +STR_DATE_SHORT :{STRING} {NUM} +STR_DATE_LONG :{STRING} {STRING} {NUM} ######## diff -r 9fce095970bb -r d0fc5d926679 lang/russian.txt --- a/lang/russian.txt Mon Mar 19 21:42:05 2007 +0000 +++ b/lang/russian.txt Mon Mar 19 22:08:18 2007 +0000 @@ -3147,6 +3147,9 @@ STR_MEASURE_AREA_HEIGHTDIFF :{BLACK}Площадь: {NUM} x {NUM}{}Разница высот: {NUM} м ############ Date formatting +STR_DATE_TINY :{STRING}.{STRING}.{NUM} +STR_DATE_SHORT :{STRING} {NUM} +STR_DATE_LONG :{STRING} {STRING} {NUM} ######## diff -r 9fce095970bb -r d0fc5d926679 lang/simplified_chinese.txt --- a/lang/simplified_chinese.txt Mon Mar 19 21:42:05 2007 +0000 +++ b/lang/simplified_chinese.txt Mon Mar 19 22:08:18 2007 +0000 @@ -3110,6 +3110,9 @@ STR_MEASURE_AREA_HEIGHTDIFF :{BLACK}面积:{NUM} x {NUM}{}高度差:{NUM}米 ############ Date formatting +STR_DATE_TINY :{STRING}-{STRING}-{NUM} +STR_DATE_SHORT :{STRING} {NUM} +STR_DATE_LONG :{STRING} {STRING} {NUM} ######## diff -r 9fce095970bb -r d0fc5d926679 lang/slovak.txt --- a/lang/slovak.txt Mon Mar 19 21:42:05 2007 +0000 +++ b/lang/slovak.txt Mon Mar 19 22:08:18 2007 +0000 @@ -3199,6 +3199,9 @@ STR_MEASURE_AREA_HEIGHTDIFF :{BLACK}Plocha: {NUM} x {NUM}{}Výškový rozdiel: {NUM} m ############ Date formatting +STR_DATE_TINY :{STRING}-{STRING}-{NUM} +STR_DATE_SHORT :{STRING} {NUM} +STR_DATE_LONG :{STRING} {STRING} {NUM} ######## diff -r 9fce095970bb -r d0fc5d926679 lang/slovenian.txt --- a/lang/slovenian.txt Mon Mar 19 21:42:05 2007 +0000 +++ b/lang/slovenian.txt Mon Mar 19 22:08:18 2007 +0000 @@ -3213,6 +3213,9 @@ STR_MEASURE_AREA_HEIGHTDIFF :{BLACK}Območje: {NUM} x {NUM}{}Višinska razlika: {NUM} m ############ Date formatting +STR_DATE_TINY :{STRING}-{STRING}-{NUM} +STR_DATE_SHORT :{STRING} {NUM} +STR_DATE_LONG :{STRING} {STRING} {NUM} ######## diff -r 9fce095970bb -r d0fc5d926679 lang/spanish.txt --- a/lang/spanish.txt Mon Mar 19 21:42:05 2007 +0000 +++ b/lang/spanish.txt Mon Mar 19 22:08:18 2007 +0000 @@ -3135,6 +3135,9 @@ STR_MEASURE_AREA_HEIGHTDIFF :{BLACK}Área: {NUM} x {NUM}{}Diferencia altura: {NUM} m ############ Date formatting +STR_DATE_TINY :{STRING}-{STRING}-{NUM} +STR_DATE_SHORT :{STRING} {NUM} +STR_DATE_LONG :{STRING} {STRING} {NUM} ######## diff -r 9fce095970bb -r d0fc5d926679 lang/swedish.txt --- a/lang/swedish.txt Mon Mar 19 21:42:05 2007 +0000 +++ b/lang/swedish.txt Mon Mar 19 22:08:18 2007 +0000 @@ -3135,6 +3135,9 @@ STR_MEASURE_AREA_HEIGHTDIFF :{BLACK}Yta: {NUM} x {NUM}{}Höjdskillnad: {NUM} m ############ Date formatting +STR_DATE_TINY :{STRING}-{STRING}-{NUM} +STR_DATE_SHORT :{STRING} {NUM} +STR_DATE_LONG :{STRING} {STRING} {NUM} ######## diff -r 9fce095970bb -r d0fc5d926679 lang/traditional_chinese.txt --- a/lang/traditional_chinese.txt Mon Mar 19 21:42:05 2007 +0000 +++ b/lang/traditional_chinese.txt Mon Mar 19 22:08:18 2007 +0000 @@ -3133,6 +3133,9 @@ STR_MEASURE_AREA_HEIGHTDIFF :{BLACK}區域: {NUM} x {NUM}{}高度差: {NUM} m ############ Date formatting +STR_DATE_TINY :{STRING}-{STRING}-{NUM} +STR_DATE_SHORT :{STRING} {NUM} +STR_DATE_LONG :{2:NUM} 年 {1:STRING} 月 {0:STRING} 日 ######## diff -r 9fce095970bb -r d0fc5d926679 lang/turkish.txt --- a/lang/turkish.txt Mon Mar 19 21:42:05 2007 +0000 +++ b/lang/turkish.txt Mon Mar 19 22:08:18 2007 +0000 @@ -3127,5 +3127,8 @@ STR_MEASURE_AREA_HEIGHTDIFF :{BLACK}Alan: {NUM} x {NUM}{}Yükseklik farkı: {NUM} m ############ Date formatting +STR_DATE_TINY :{STRING}-{STRING}-{NUM} +STR_DATE_SHORT :{STRING} {NUM} +STR_DATE_LONG :{STRING} {STRING} {NUM} ######## diff -r 9fce095970bb -r d0fc5d926679 lang/ukrainian.txt --- a/lang/ukrainian.txt Mon Mar 19 21:42:05 2007 +0000 +++ b/lang/ukrainian.txt Mon Mar 19 22:08:18 2007 +0000 @@ -3298,6 +3298,9 @@ STR_MEASURE_AREA_HEIGHTDIFF :{BLACK}Ділянка: {NUM} x {NUM}{}Різниця висот: {NUM} м ############ Date formatting +STR_DATE_TINY :{STRING}-{STRING}-{NUM} +STR_DATE_SHORT :{STRING} {NUM} +STR_DATE_LONG :{STRING} {STRING} {NUM} ######## diff -r 9fce095970bb -r d0fc5d926679 lang/unfinished/croatian.txt --- a/lang/unfinished/croatian.txt Mon Mar 19 21:42:05 2007 +0000 +++ b/lang/unfinished/croatian.txt Mon Mar 19 22:08:18 2007 +0000 @@ -2894,6 +2894,9 @@ STR_MEASURE_AREA_HEIGHTDIFF :{BLACK}Područje:{NUM}x{NUM}Visinska razlika:{NUM} m ############ Date formatting +STR_DATE_TINY :{STRING}-{STRING}-{NUM} +STR_DATE_SHORT :{STRING} {NUM} +STR_DATE_LONG :{STRING} {STRING} {NUM} ######## diff -r 9fce095970bb -r d0fc5d926679 strings.c --- a/strings.c Mon Mar 19 21:42:05 2007 +0000 +++ b/strings.c Mon Mar 19 22:08:18 2007 +0000 @@ -240,9 +240,17 @@ } -// This function takes a C-string and allocates a temporary string ID. -// The duration of the bound string is valid only until the next GetString, -// so be careful. +/** + * This function takes a C-string and allocates a temporary string ID. + * The StringID of the bound string is valid until BindCString is called + * another NUM_BOUND_STRINGS times. So be careful when using it. + * + * @note formatting a DATE_TINY calls BindCString twice, thus reduces the + * amount of 'user' bound strings by 2. + * @todo rewrite the BindCString system to make the limit flexible and + * non-round-robin. For example by using smart pointers that free + * the allocated StringID when they go out-of-scope/are freed. + */ StringID BindCString(const char *str) { int idx = (++_bind_index) & (NUM_BOUND_STRINGS - 1); @@ -346,40 +354,42 @@ static char *FormatYmdString(char *buff, Date date, const char* last) { YearMonthDay ymd; - + int32 args[3]; ConvertDateToYMD(date, &ymd); - buff = strecpy(buff, GetStringPtr(ymd.day + STR_01AC_1ST - 1), last); - buff = strecpy(buff, " ", last); - buff = strecpy(buff, GetStringPtr(STR_0162_JAN + ymd.month), last); - buff = strecpy(buff, " ", last); - - return FormatNoCommaNumber(buff, ymd.year, last); + args[0] = ymd.day + STR_01AC_1ST - 1; + args[1] = STR_0162_JAN + ymd.month; + args[2] = ymd.year; + return FormatString(buff, GetStringPtr(STR_DATE_LONG), args, 0, last); } static char *FormatMonthAndYear(char *buff, Date date, const char* last) { YearMonthDay ymd; - + int32 args[2]; ConvertDateToYMD(date, &ymd); - buff = strecpy(buff, GetStringPtr(STR_MONTH_JAN + ymd.month), last); - buff = strecpy(buff, " ", last); - - return FormatNoCommaNumber(buff, ymd.year, last); + args[0] = STR_MONTH_JAN + ymd.month; + args[1] = ymd.year; + return FormatString(buff, GetStringPtr(STR_DATE_SHORT), args, 0, last); } static char *FormatTinyDate(char *buff, Date date, const char* last) { YearMonthDay ymd; - + int32 args[3]; + char day[3]; + char month[3]; ConvertDateToYMD(date, &ymd); - buff += snprintf( - buff, last - buff + 1, - " %02i-%02i-%04i", ymd.day, ymd.month + 1, ymd.year - ); - return buff; + /* We want to zero-pad the days and months */ + snprintf(day, lengthof(day), "%02i", ymd.day); + snprintf(month, lengthof(month), "%02i", ymd.month + 1); + + args[0] = BindCString(day); + args[1] = BindCString(month); + args[2] = ymd.year; + return FormatString(buff, GetStringPtr(STR_DATE_TINY), args, 0, last); } static char *FormatGenericCurrency(char *buff, const CurrencySpec *spec, int64 number, bool compact, const char* last)