author | zautrix <zautrix> | 2004-10-23 22:58:21 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-23 22:58:21 (UTC) |
commit | fcea043d2200bb4bb0b1146a69204af15fb58a7d (patch) (unidiff) | |
tree | c2c210290c02f20af3b307f4c4e47ba8915f7a05 /microkde | |
parent | 22c26311ca936fa1036e406c86e0178c16acd090 (diff) | |
download | kdepimpi-fcea043d2200bb4bb0b1146a69204af15fb58a7d.zip kdepimpi-fcea043d2200bb4bb0b1146a69204af15fb58a7d.tar.gz kdepimpi-fcea043d2200bb4bb0b1146a69204af15fb58a7d.tar.bz2 |
kopimail translation
-rw-r--r-- | microkde/kdecore/klocale.cpp | 62 |
1 files changed, 56 insertions, 6 deletions
diff --git a/microkde/kdecore/klocale.cpp b/microkde/kdecore/klocale.cpp index d3b04dc..1da1e99 100644 --- a/microkde/kdecore/klocale.cpp +++ b/microkde/kdecore/klocale.cpp | |||
@@ -1,165 +1,215 @@ | |||
1 | #include <qregexp.h> | 1 | #include <qregexp.h> |
2 | #include <qapplication.h> | 2 | #include <qapplication.h> |
3 | 3 | ||
4 | #include "kdebug.h" | 4 | #include "kdebug.h" |
5 | #include "kcalendarsystemgregorian.h" | 5 | #include "kcalendarsystemgregorian.h" |
6 | 6 | ||
7 | #include "klocale.h" | 7 | #include "klocale.h" |
8 | 8 | ||
9 | #include <qstringlist.h> | 9 | #include <qstringlist.h> |
10 | QStringList missingTrans; | 10 | |
11 | //#define COLLECT_TRANSLATION | ||
12 | |||
11 | 13 | ||
12 | QDict<QString> *mLocaleDict = 0; | 14 | QDict<QString> *mLocaleDict = 0; |
13 | void setLocaleDict( QDict<QString> * dict ) | 15 | void setLocaleDict( QDict<QString> * dict ) |
14 | { | 16 | { |
15 | mLocaleDict = dict; | 17 | mLocaleDict = dict; |
16 | 18 | ||
17 | } | 19 | } |
20 | |||
21 | #ifdef COLLECT_TRANSLATION | ||
22 | |||
23 | QStringList missingTrans; | ||
24 | QStringList existingTrans1; | ||
25 | QStringList existingTrans2; | ||
26 | |||
18 | void addMissing(const char *text) | 27 | void addMissing(const char *text) |
19 | { | 28 | { |
20 | return; | 29 | |
21 | QString mis ( text ); | 30 | QString mis ( text ); |
22 | if ( !missingTrans.contains( mis ) ) | 31 | if ( !missingTrans.contains( mis ) ) |
23 | missingTrans.append(mis); | 32 | missingTrans.append(mis); |
24 | 33 | ||
25 | } | 34 | } |
35 | void addExist(const char *text,QString trans ) | ||
36 | { | ||
37 | //return; | ||
38 | QString mis ( text ); | ||
39 | if ( !existingTrans1.contains( mis ) ) { | ||
40 | existingTrans1.append(mis); | ||
41 | existingTrans2.append(trans); | ||
42 | |||
43 | } | ||
44 | |||
45 | } | ||
26 | 46 | ||
27 | #include <qfile.h> | 47 | #include <qfile.h> |
28 | #include <qtextstream.h> | 48 | #include <qtextstream.h> |
29 | #include <qtextcodec.h> | 49 | #include <qtextcodec.h> |
50 | #endif | ||
30 | void dumpMissing() | 51 | void dumpMissing() |
31 | { | 52 | { |
32 | return; | 53 | #ifdef COLLECT_TRANSLATION |
33 | QString fileName = "/tmp/usertrans.txt"; | 54 | QString fileName = "/tmp/usernewtrans.txt"; |
34 | QFile file( fileName ); | 55 | QFile file( fileName ); |
35 | if (!file.open( IO_WriteOnly ) ) { | 56 | if (!file.open( IO_WriteOnly ) ) { |
36 | return ; | 57 | return ; |
37 | } | 58 | } |
38 | QTextStream ts( &file ); | 59 | QTextStream ts( &file ); |
39 | ts.setCodec( QTextCodec::codecForName("utf8") ); | 60 | ts.setCodec( QTextCodec::codecForName("utf8") ); |
40 | 61 | ||
41 | int i; | 62 | int i; |
42 | for ( i = 0; i< missingTrans.count(); ++i ) { | 63 | for ( i = 0; i< missingTrans.count(); ++i ) { |
43 | 64 | ||
44 | QString text = missingTrans[i].replace( QRegExp("\n"),"\\n" ); | 65 | QString text = missingTrans[i].replace( QRegExp("\n"),"\\n" ); |
45 | ts << "{ \""<<text<< "\",\""<< text <<"\" },\n"; | 66 | ts << "{ \""<<text<< "\",\""<< text <<"\" },\n"; |
46 | 67 | ||
47 | } | 68 | } |
48 | file.close(); | 69 | file.close(); |
49 | } | 70 | { |
71 | QString fileName = "/tmp/usertrans.txt"; | ||
72 | QFile file( fileName ); | ||
73 | if (!file.open( IO_WriteOnly ) ) { | ||
74 | return ; | ||
75 | } | ||
76 | QTextStream ts( &file ); | ||
77 | ts.setCodec( QTextCodec::codecForName("utf8") ); | ||
78 | |||
79 | int i; | ||
80 | for ( i = 0; i< existingTrans1.count(); ++i ) { | ||
81 | |||
82 | QString text = existingTrans1[i].replace( QRegExp("\n"),"\\n" ); | ||
83 | QString text2 = existingTrans2[i].replace( QRegExp("\n"),"\\n" ); | ||
84 | ts << "{ \""<<text<< "\",\""<< text2 <<"\" },\n"; | ||
50 | 85 | ||
86 | } | ||
87 | file.close(); | ||
88 | } | ||
89 | #endif | ||
90 | } | ||
51 | QString i18n(const char *text) | 91 | QString i18n(const char *text) |
52 | { | 92 | { |
53 | if ( ! mLocaleDict ) { | 93 | if ( ! mLocaleDict ) { |
94 | #ifdef COLLECT_TRANSLATION | ||
54 | addMissing( text ); | 95 | addMissing( text ); |
96 | #endif | ||
55 | return QString( text ); | 97 | return QString( text ); |
56 | } | 98 | } |
57 | else { | 99 | else { |
58 | QString* ret = mLocaleDict->find(QString(text)) ; | 100 | QString* ret = mLocaleDict->find(QString(text)) ; |
59 | if ( ret == 0 ) { | 101 | if ( ret == 0 ) { |
102 | #ifdef COLLECT_TRANSLATION | ||
60 | addMissing( text ); | 103 | addMissing( text ); |
104 | #endif | ||
61 | return QString( text ); | 105 | return QString( text ); |
62 | } | 106 | } |
63 | else { | 107 | else { |
64 | if ( (*ret).isEmpty() ) { | 108 | if ( (*ret).isEmpty() ) { |
109 | #ifdef COLLECT_TRANSLATION | ||
65 | addMissing( text ); | 110 | addMissing( text ); |
111 | #endif | ||
66 | return QString( text ); | 112 | return QString( text ); |
67 | } | 113 | } |
68 | else | 114 | else { |
115 | #ifdef COLLECT_TRANSLATION | ||
116 | addExist( text, *ret ); | ||
117 | #endif | ||
69 | return (*ret); | 118 | return (*ret); |
119 | } | ||
70 | } | 120 | } |
71 | } | 121 | } |
72 | 122 | ||
73 | } | 123 | } |
74 | 124 | ||
75 | QString i18n(const char *,const char *text) | 125 | QString i18n(const char *,const char *text) |
76 | { | 126 | { |
77 | return i18n( text ); | 127 | return i18n( text ); |
78 | } | 128 | } |
79 | 129 | ||
80 | QString i18n(const char *text1, const char *textn, int num) | 130 | QString i18n(const char *text1, const char *textn, int num) |
81 | { | 131 | { |
82 | if ( num == 1 ) return i18n( text1 ); | 132 | if ( num == 1 ) return i18n( text1 ); |
83 | else { | 133 | else { |
84 | QString text = i18n( textn ); | 134 | QString text = i18n( textn ); |
85 | int pos = text.find( "%n" ); | 135 | int pos = text.find( "%n" ); |
86 | if ( pos >= 0 ) text.replace( pos, 2, QString::number( num ) ); | 136 | if ( pos >= 0 ) text.replace( pos, 2, QString::number( num ) ); |
87 | return text; | 137 | return text; |
88 | } | 138 | } |
89 | } | 139 | } |
90 | 140 | ||
91 | inline void put_it_in( QChar *buffer, uint& index, const QString &s ) | 141 | inline void put_it_in( QChar *buffer, uint& index, const QString &s ) |
92 | { | 142 | { |
93 | for ( uint l = 0; l < s.length(); l++ ) | 143 | for ( uint l = 0; l < s.length(); l++ ) |
94 | buffer[index++] = s.at( l ); | 144 | buffer[index++] = s.at( l ); |
95 | } | 145 | } |
96 | 146 | ||
97 | inline void put_it_in( QChar *buffer, uint& index, int number ) | 147 | inline void put_it_in( QChar *buffer, uint& index, int number ) |
98 | { | 148 | { |
99 | buffer[index++] = number / 10 + '0'; | 149 | buffer[index++] = number / 10 + '0'; |
100 | buffer[index++] = number % 10 + '0'; | 150 | buffer[index++] = number % 10 + '0'; |
101 | } | 151 | } |
102 | 152 | ||
103 | static int readInt(const QString &str, uint &pos) | 153 | static int readInt(const QString &str, uint &pos) |
104 | { | 154 | { |
105 | if (!str.at(pos).isDigit()) return -1; | 155 | if (!str.at(pos).isDigit()) return -1; |
106 | int result = 0; | 156 | int result = 0; |
107 | for (; str.length() > pos && str.at(pos).isDigit(); pos++) | 157 | for (; str.length() > pos && str.at(pos).isDigit(); pos++) |
108 | { | 158 | { |
109 | result *= 10; | 159 | result *= 10; |
110 | result += str.at(pos).digitValue(); | 160 | result += str.at(pos).digitValue(); |
111 | } | 161 | } |
112 | 162 | ||
113 | return result; | 163 | return result; |
114 | } | 164 | } |
115 | 165 | ||
116 | KLocale::KLocale() : mCalendarSystem( 0 ) | 166 | KLocale::KLocale() : mCalendarSystem( 0 ) |
117 | { | 167 | { |
118 | 168 | ||
119 | m_decimalSymbol = "."; | 169 | m_decimalSymbol = "."; |
120 | m_positiveSign = ""; | 170 | m_positiveSign = ""; |
121 | m_negativeSign = "-"; | 171 | m_negativeSign = "-"; |
122 | m_thousandsSeparator = ","; | 172 | m_thousandsSeparator = ","; |
123 | 173 | ||
124 | 174 | ||
125 | 175 | ||
126 | 176 | ||
127 | mWeekStartsMonday = true; | 177 | mWeekStartsMonday = true; |
128 | mHourF24Format = true; | 178 | mHourF24Format = true; |
129 | mIntDateFormat = Default; | 179 | mIntDateFormat = Default; |
130 | mIntTimeFormat = Default; | 180 | mIntTimeFormat = Default; |
131 | mLanguage = 0; | 181 | mLanguage = 0; |
132 | mDateFormat = "%a %Y %b %d"; | 182 | mDateFormat = "%a %Y %b %d"; |
133 | mDateFormatShort = "%Y-%m-%d"; | 183 | mDateFormatShort = "%Y-%m-%d"; |
134 | mTimeZoneList << ("-11:00 US/Samoa") | 184 | mTimeZoneList << ("-11:00 US/Samoa") |
135 | << ("-10:00 US/Hawaii") | 185 | << ("-10:00 US/Hawaii") |
136 | << ("-09:00 US/Alaska") | 186 | << ("-09:00 US/Alaska") |
137 | << ("-08:00 US/Pacific") | 187 | << ("-08:00 US/Pacific") |
138 | << ("-07:00 US/Mountain") | 188 | << ("-07:00 US/Mountain") |
139 | << ("-06:00 US/Central") | 189 | << ("-06:00 US/Central") |
140 | << ("-05:00 US/Eastern") | 190 | << ("-05:00 US/Eastern") |
141 | << ("-04:00 Brazil/West") | 191 | << ("-04:00 Brazil/West") |
142 | << ("-03:00 Brazil/East") | 192 | << ("-03:00 Brazil/East") |
143 | << ("-02:00 Brazil/DeNoronha") | 193 | << ("-02:00 Brazil/DeNoronha") |
144 | << ("-01:00 Atlantic/Azores") | 194 | << ("-01:00 Atlantic/Azores") |
145 | << (" 00:00 Europe/London(UTC)") | 195 | << (" 00:00 Europe/London(UTC)") |
146 | << ("+01:00 Europe/Oslo(CET)") | 196 | << ("+01:00 Europe/Oslo(CET)") |
147 | << ("+02:00 Europe/Helsinki") | 197 | << ("+02:00 Europe/Helsinki") |
148 | << ("+03:00 Europe/Moscow") | 198 | << ("+03:00 Europe/Moscow") |
149 | << ("+04:00 Indian/Mauritius") | 199 | << ("+04:00 Indian/Mauritius") |
150 | << ("+05:00 Indian/Maldives") | 200 | << ("+05:00 Indian/Maldives") |
151 | << ("+06:00 Indian/Chagos") | 201 | << ("+06:00 Indian/Chagos") |
152 | << ("+07:00 Asia/Bangkok") | 202 | << ("+07:00 Asia/Bangkok") |
153 | << ("+08:00 Asia/Hongkong") | 203 | << ("+08:00 Asia/Hongkong") |
154 | << ("+09:00 Asia/Tokyo") | 204 | << ("+09:00 Asia/Tokyo") |
155 | << ("+10:00 Asia/Vladivostok") | 205 | << ("+10:00 Asia/Vladivostok") |
156 | << ("+11:00 Asia/Magadan") | 206 | << ("+11:00 Asia/Magadan") |
157 | << ("+12:00 Asia/Kamchatka") | 207 | << ("+12:00 Asia/Kamchatka") |
158 | // << (" xx:xx User defined offset") | 208 | // << (" xx:xx User defined offset") |
159 | << i18n (" Local Time"); | 209 | << i18n (" Local Time"); |
160 | mSouthDaylight = false; | 210 | mSouthDaylight = false; |
161 | mTimeZoneOffset = 0; | 211 | mTimeZoneOffset = 0; |
162 | daylightEnabled = false; | 212 | daylightEnabled = false; |
163 | } | 213 | } |
164 | 214 | ||
165 | void KLocale::setDateFormat( QString s ) | 215 | void KLocale::setDateFormat( QString s ) |