6 #include "../../cfg/config.h"
7 #include "../../common/misc/coding/coding.h"
8 #include "../../common/misc/cfg.h"
9 #include "../../common/misc/misc.h"
11 unsigned char line
[1000];
14 INI_Section
*cfg_info
;
16 void WriteOutput(char *mystring
)
18 unsigned char buffer
[400];
20 EncodeUnicode(buffer
,mystring
,strlen(mystring
));
21 fwrite(buffer
,1,strlen(mystring
)*2,output
);
26 fwrite(buffer
,1,4,output
);
29 void ProcessSourceFile(char *filename
)
34 unsigned char buffer
[10000],buffer2
[500];
37 printf("Processing source file %s\n",filename
);
39 file
= fopen(filename
, "rb");
42 num
=fread(buffer
, 1, 10000, file
);
46 pdest
= strstr( line
, "printmsgerr" );
48 start
= strlen(line
) - strlen(pdest
) + 1 + 11;
50 pdest
= strstr( line
, "printmsg" );
51 if (pdest
!= NULL
) start
= strlen(line
) - strlen(pdest
) + 1 + 8;
56 while (stop
< ((int)strlen(line
))) {
58 if (line
[stop
-1] != '\\' && line
[stop
] == '"') {
64 sprintf(buffer2
,"F%04i=%s",outputnum
,line
+start
);
65 buffer2
[stop
-start
+6+1] = 0;
75 line
[strlen(line
)+1] = 0;
76 line
[strlen(line
)] = buffer
[i
];
83 void RemoveDuplicatedStrings(char *filename
)
86 unsigned char buffer
[500],buffer2
[500],buff2
[50];
87 INI_Entry
*e
,*ebackup
,*e2
;
90 printf("Removing duplicated strings from %s\n",filename
);
92 EncodeUnicode (buff2
, "common", 6);
94 cfg_info
= INI_ReadFile(filename
,true);
95 output
= fopen(filename
, "wb");
101 fwrite(buffer
,1,2,output
);
102 sprintf(buffer
,"# Localization file for Gammu (www.mwiacek.com) version %s",VERSION
);
105 WriteOutput("[common]");
107 e
= INI_FindLastSectionEntry(cfg_info
, buff2
,true);
110 if (e
== NULL
) break;
112 sprintf(buffer
,"%s",DecodeUnicodeString(e
->EntryName
));
113 if (strlen(buffer
) == 5 && strncmp("F", buffer
, 1) == 0) {
114 num
= atoi(buffer
+2);
121 if (e2
== NULL
) break;
123 sprintf(buffer
,"%s",DecodeUnicodeString(e2
->EntryName
));
124 if (strlen(buffer
) == 5 && strncmp("F", buffer
, 1) == 0) {
125 num2
= atoi(buffer
+2);
128 if (num2
!= -1 && num2
< num
) {
129 if (mywstrncmp(e2
->EntryValue
, e
->EntryValue
, 0)) {
135 if (number
== num
) break;
138 sprintf(buffer2
,"F%04i=",outputnum
);
139 EncodeUnicode(buffer
,buffer2
,6);
140 fwrite(buffer
,1,12,output
);
141 fwrite(e
->EntryValue
,1,UnicodeLength(e
->EntryValue
)*2,output
);
153 void ProcessLangFile(char *filename
)
155 INI_Section
*cfg_lang
;
156 INI_Entry
*e
,*e_lang
,*e2
;
159 unsigned char buffer
[10000],buffer2
[10000],buff2
[50];
161 printf("Processing file %s\n",filename
);
163 cfg_lang
= INI_ReadFile(filename
,true);
164 output
= fopen(filename
, "wb");
168 fwrite(buffer
,1,2,output
);
169 sprintf(buffer
,"# Localization file for Gammu (www.mwiacek.com) version %s",VERSION
);
172 WriteOutput("[common]");
174 EncodeUnicode (buff2
, "common", 6);
176 e2
= INI_FindLastSectionEntry(cfg_lang
, buff2
, true);
177 e
= INI_FindLastSectionEntry(cfg_info
, buff2
, true);
179 if (e
== NULL
) break;
181 sprintf(buffer
,"%s",DecodeUnicodeString(e
->EntryName
));
182 if (strlen(buffer
) == 5 && strncmp("F", buffer
, 1) == 0) {
183 num
= atoi(buffer
+2);
187 sprintf(buffer2
,"F%04i=",num
);
188 EncodeUnicode(buffer
,buffer2
,6);
189 fwrite(buffer
,1,12,output
);
190 fwrite(e
->EntryValue
,1,UnicodeLength(e
->EntryValue
)*2,output
);
194 if (e_lang
== NULL
) break;
196 sprintf(buffer
,"%s",DecodeUnicodeString(e_lang
->EntryName
));
197 if (strlen(buffer
) == 5 && strncmp("F", buffer
, 1) == 0) {
198 num_lang
= atoi(buffer
+2);
201 if (mywstrncmp(e_lang
->EntryValue
, e
->EntryValue
, 0)) {
202 sprintf(buffer2
,"T%04i",num_lang
);
203 EncodeUnicode(buffer
,buffer2
,6);
204 retval_lang
= INI_GetValue(cfg_lang
, buff2
, buffer
,true);
205 if (retval_lang
!= NULL
) {
206 sprintf(buffer2
,"T%04i=",num
);
207 EncodeUnicode(buffer
,buffer2
,6);
208 fwrite(buffer
,1,12,output
);
209 fwrite(retval_lang
,1,UnicodeLength(retval_lang
)*2,output
);
215 e_lang
= e_lang
->Prev
;
224 int main(int argc
, char *argv
[])
226 unsigned char buffer
[400];
229 output
= fopen("../../../../docs/docs/locale/gammu_us.txt", "wb");
231 output
= fopen("../../docs/docs/locale/gammu_us.txt", "wb");
235 fwrite(buffer
,1,2,output
);
236 sprintf(buffer
,"# Localization file for Gammu (www.mwiacek.com) version %s",VERSION
);
239 WriteOutput("[common]");
240 WriteOutput("F0001=\"No error.\"");
241 WriteOutput("F0002=\"Error opening device. Unknown/busy or no permissions.\"");
242 WriteOutput("F0003=\"Error setting device DTR or RTS\"");
243 WriteOutput("F0004=\"Error setting device speed. Maybe speed not supported.\"");
244 WriteOutput("F0005=\"Error writing device.\"");
245 WriteOutput("F0006=\"No response in specified timeout. Probably phone not connected.\"");
246 WriteOutput("F0007=\"Unknown response from phone. See readme.txt, how to report it.\"");
247 WriteOutput("F0008=\"Unknown connection type string. Check config file.\"");
248 WriteOutput("F0009=\"Unknown model type string. Check config file.\"");
249 WriteOutput("F0010=\"Some required functions not compiled for your OS. Please contact.\"");
250 WriteOutput("F0011=\"Function not supported by phone.\"");
251 WriteOutput("F0012=\"Entry is empty.\"");
252 WriteOutput("F0013=\"Unknown error.\"");
253 WriteOutput("F0014=\"Unknown error.\"");
254 WriteOutput("F0015=\"Security error. Maybe no PIN ?\"");
255 WriteOutput("F0016=\"Invalid location. Maybe too high ?\"");
256 WriteOutput("F0017=\"Function not implemented. Help required.\"");
257 WriteOutput("F0018=\"Can't open specified file. Read only ?\"");
258 WriteOutput("F0019=\"Memory full.\"");
259 WriteOutput("F0020=\"More memory required...\"");
260 WriteOutput("F0021=\"Permission to file/device required...\"");
261 WriteOutput("F0022=\"Family\"");
262 WriteOutput("F0023=\"VIP\"");
263 WriteOutput("F0024=\"Friends\"");
264 WriteOutput("F0025=\"Colleagues\"");
265 WriteOutput("F0026=\"Other\"");
266 WriteOutput("F0027=\"Inbox\"");
267 WriteOutput("F0028=\"Outbox\"");
268 WriteOutput("F0029=\"Empty SMSC number. Set in phone or use -smscnumber\"");
269 WriteOutput("F0030=\"You're inside phone menu (during editing ?). Leave it and try again.\"");
270 WriteOutput("F0031=\"Personal\"");
271 WriteOutput("F0032=\"Car\"");
272 WriteOutput("F0033=\"Headset\"");
273 WriteOutput("F0034=\"General\"");
274 WriteOutput("F0035=\"Silent\"");
275 WriteOutput("F0036=\"Meeting\"");
276 WriteOutput("F0037=\"Outdoor\"");
277 WriteOutput("F0038=\"Pager\"");
278 WriteOutput("F0039=\"Discreet\"");
279 WriteOutput("F0040=\"Loud\"");
280 WriteOutput("F0041=\"My style\"");
281 WriteOutput("F0042=\"Function is during writing. If want help, please contact with authors.\"");
282 WriteOutput("F0043=\"Error during reading device\"");
283 WriteOutput("F0044=\"Can't set parity on device\"");
284 WriteOutput("F0045=\"Phone is disabled and connected to charger\"");
285 WriteOutput("F0046=\"File format not supported by Gammu\"");
288 ProcessSourceFile("../../../../gammu/gammu.c");
290 ProcessSourceFile("../../gammu/gammu.c");
295 RemoveDuplicatedStrings("../../../../docs/docs/locale/gammu_us.txt");
296 cfg_info
= INI_ReadFile("../../../../docs/docs/locale/gammu_us.txt",true);
298 ProcessLangFile("../../../../docs/docs/locale/gammu_pl.txt");
299 ProcessLangFile("../../../../docs/docs/locale/gammu_de.txt");
300 ProcessLangFile("../../../../docs/docs/locale/gammu_cs.txt");
302 RemoveDuplicatedStrings("../../docs/docs/locale/gammu_us.txt");
303 cfg_info
= INI_ReadFile("../../docs/docs/locale/gammu_us.txt",true);
305 ProcessLangFile("../../docs/docs/locale/gammu_pl.txt");
306 ProcessLangFile("../../docs/docs/locale/gammu_de.txt");
307 ProcessLangFile("../../docs/docs/locale/gammu_cs.txt");
314 /* How should editor hadle tabs in this file? Add editor commands here.
315 * vim: noexpandtab sw=8 ts=8 sts=8: