• R/O
  • SSH
  • HTTPS

svardos: Commit


Commit MetaInfo

Revision603 (tree)
Time2022-02-03 21:38:38
Authormateuszviste

Log Message

NLS support

Change Summary

Incremental Difference

--- localcfg/trunk/nls_lang/en.txt (nonexistent)
+++ localcfg/trunk/nls_lang/en.txt (revision 603)
@@ -0,0 +1,53 @@
1+#
2+# LOCALCFG TRANSLATION FILE
3+#
4+# LANGUAGE: ENGLISH
5+# TRANSLATOR: MATEUSZ VISTE
6+#
7+
8+### HELP SCREEN ###########################################################
9+
10+0.0:version
11+0.1:creates or edits COUNTRY.SYS local preferences
12+0.2:usage: localcfg [COUNTRY.SYS] [options]
13+0.3:options:
14+
15+0.10:/country:XX set the country code to XX (1=USA, 33=France, 48=Poland, etc)
16+0.11:/cp:XXX adapts country data for codepage XXX (example: '437')
17+0.12:/decim:X reconfigures the decimal symbol to be 'X'
18+0.13:/thous:X reconfigures the thousands symbol to be 'X'
19+0.14:/datesep:X sets the date separator to 'X' (for example '/')
20+0.15:/datefmt:X sets the date format, can be: MDY, DMY or YMD
21+0.16:/timesep:X sets the time separator to 'X' (for example ':')
22+0.17:/timefmt:X sets the time format: 0=12h with AM/PM or 1=24h
23+0.18:/curr:XXX sets the currency to XXX (a string of 1 to 4 characters)
24+0.19:/currpos:X sets the currency symbol position to X, where X is either
25+0.20: 0=currency precedes the value, 1=currency follows the value and
26+0.21: 2=currency replaces the decimal sign
27+0.22:/currspc:X space between the currency and the value (0=no, 1=yes)
28+0.23:/currprec:X currency's precision (number of decimal digits, 0..9)
29+0.24:/yesno:XY sets the 'Yes/No' letter to XY (default: YN)
30+
31+0.50:If COUNTRY.SYS location is not provided, then localcfg tries loading it
32+0.51:from %DOSDIR%\CFG\COUNTRY.SYS
33+
34+
35+### INFO SCREEN ###########################################################
36+
37+7.0:Country code.......:
38+7.1:Codepage...........:
39+7.2:Decimal separator..:
40+7.3:Thousands separator:
41+7.4:Date format........:
42+7.5:Time format........:
43+7.6:Yes/No characters..:
44+7.7:Currency example...:
45+
46+7.9:Make sure that your CONFIG.SYS contains this directive:
47+
48+### ERROR MESSAGES ########################################################
49+
50+9.0:ERROR: file path can be provided only once.
51+9.1:ERROR: bad path to file
52+9.2:ERROR: failed to read the file
53+9.3:ERROR: invalid parameter syntax
--- localcfg/trunk/nls_lang/pl_utf8.txt (nonexistent)
+++ localcfg/trunk/nls_lang/pl_utf8.txt (revision 603)
@@ -0,0 +1,53 @@
1+#
2+# LOCALCFG TRANSLATION FILE
3+#
4+# LANGUAGE: POLISH
5+# TRANSLATOR: MATEUSZ VISTE
6+#
7+
8+### HELP SCREEN ###########################################################
9+
10+0.0:wersja
11+0.1:tworzy lub zmienia lokalne preferencje COUNTRY.SYS
12+0.2:użycie: localcfg [COUNTRY.SYS] [opcje]
13+0.3:opcje
14+
15+0.10:/country:XX ustawia kod kraju na XX (1=USA, 33=Francja, 48=Polska, itd)
16+0.11:/cp:XXX adapts country data for codepage XXX (przykład: '437')
17+0.12:/decim:X ustawia separator dziesiętny 'X'
18+0.13:/thous:X ustawia separator tysięczny 'X'
19+0.14:/datesep:X ustawia separator daty 'X' (np. '/')
20+0.15:/datefmt:X ustawia jeden z formatów daty: MDY, DMY lub YMD
21+0.16:/timesep:X ustawia separator czasu 'X' (np. ':')
22+0.17:/timefmt:X ustawia format godziny: 0=12h z AM/PM lub 1=24h
23+0.18:/curr:XXX ustawia walutę XXX (ciąg od 1 do 4 znaków)
24+0.19:/currpos:X ustawia miejsce symbolu walutowego, gdzie X może być:
25+0.20: 0=symbol waluty przed sumą, 1=symbol waluty po sumie,
26+0.21: 2=symbol waluty zastępuje znak dziesiętny
27+0.22:/currspc:X spacja pomiędzy walutą a wartością (0=nie, 1=tak)
28+0.23:/currprec:X dokładność waluty (liczba pozycji dziesiętnych, 0..9)
29+0.24:/yesno:XY ustawia znaki 'Tak/Nie' (domyślnie: YN)
30+
31+0.50:Jeśli nie podasz ścieżki do COUNTRY.SYS to localcfg spróbuje załadować plik
32+0.51:%DOSDIR%\CFG\COUNTRY.SYS
33+
34+
35+### INFO SCREEN ###########################################################
36+
37+7.0:Kod kraju..........:
38+7.1:Strona kodowa......:
39+7.2:Znak dziesiętny....:
40+7.3:Separator tysięczny:
41+7.4:Format daty........:
42+7.5:Format godziny.....:
43+7.6:Znaki Tak/Nie......:
44+7.7:Przykład waluty....:
45+
46+7.9:Upewnij się, że twój plik CONFIG.SYS zawiera taki wpis:
47+
48+### ERROR MESSAGES ########################################################
49+
50+9.0:BŁĄD: ścieżka do pliku może zostać podana tylko raz.
51+9.1:BŁĄD: zła ścieżka do pliku.
52+9.2:BŁĄD: nie zdołano wczytać pliku.
53+9.3:BŁĄD: nieprawidłowa składnia parametru.
--- localcfg/trunk/Makefile (revision 602)
+++ localcfg/trunk/Makefile (revision 603)
@@ -4,10 +4,18 @@
44
55 all: localcfg.com
66
7-localcfg.com: localcfg.c country.c
8- wcl -0 -y -cc -wx -mt -lr -zp1 -we -d0 -ox localcfg.c country.c
7+localcfg.com: localcfg.c country.c deflang.c
8+ wcl -0 -y -cc -wx -mt -lr -zp1 -we -d0 -ox localcfg.c country.c deflang.c svarlang.lib/svarlngs.lib
99 upx --8086 -9 localcfg.com
1010
11+deflang.c: nls_lang\*.txt
12+ cd nls_lang
13+ utf8tocp maz pl_utf8.txt > pl.txt
14+ ..\svarlang.lib\tlumacz en pl
15+ move out.lng ..\localcfg.lng
16+ move deflang.c ..\
17+ cd ..
18+
1119 clean: .SYMBOLIC
1220 del *.obj
1321 del *.com
@@ -16,18 +24,23 @@
1624 mkdir appinfo
1725 mkdir source
1826 mkdir source\localcfg
27+ mkdir source\localcfg\nls_lang
1928 mkdir bin
2029 mkdir doc
30+ mkdir nls
2131 copy localcfg.lsm appinfo
2232 copy localcfg.com bin
33+ copy localcfg.lng nls
2334 copy *.txt doc
2435 copy *.c source\localcfg
2536 copy *.h source\localcfg
2637 copy *.txt source\localcfg
2738 copy makefile source\localcfg
28- zip -9rkDX -m localcfg.zip appinfo bin doc source
39+ copy nls_lang\*.* source\localcfg\nls_lang
40+ zip -9rkDX -m localcfg.zip appinfo bin doc nls source
2941 rmdir appinfo
3042 rmdir source\localcfg
3143 rmdir source
3244 rmdir bin
3345 rmdir doc
46+ rmdir nls
--- localcfg/trunk/localcfg.c (revision 602)
+++ localcfg/trunk/localcfg.c (revision 603)
@@ -28,40 +28,98 @@
2828 #include <stdlib.h> /* atoi() */
2929 #include <string.h> /* strchr */
3030
31+#include "svarlang.lib/svarlang.h"
32+
3133 #include "country.h"
3234
33-#define PVER "20220202"
35+#define PVER "20220203"
3436 #define PDATE "2015-2022"
3537
3638
39+enum NLS_STRINGS {
40+ NLS_HLP_VER = 0x0000,
41+ NLS_HLP_DESC = 0x0001,
42+ NLS_HLP_USAGE = 0x0002,
43+ NLS_HLP_OPTIONS = 0x0003,
44+ NLS_HLP_COUNTRY = 0x000A,
45+ NLS_HLP_CP = 0x000B,
46+ NLS_HLP_DECIM = 0x000C,
47+ NLS_HLP_THOUS = 0x000D,
48+ NLS_HLP_DATESEP = 0x000E,
49+ NLS_HLP_DATEFMT = 0x000F,
50+ NLS_HLP_TIMESEP = 0x0010,
51+ NLS_HLP_TIMEFMT = 0x0011,
52+ NLS_HLP_CURR = 0x0012,
53+ NLS_HLP_CURRPOS0 = 0x0013,
54+ NLS_HLP_CURRPOS1 = 0x0014,
55+ NLS_HLP_CURRPOS2 = 0x0015,
56+ NLS_HLP_CURRSPC = 0x0016,
57+ NLS_HLP_CURRPREC = 0x0017,
58+ NLS_HLP_YESNO = 0x0018,
59+ NLS_HLP_INFOLOC1 = 0x0032,
60+ NLS_HLP_INFOLOC2 = 0x0033,
61+
62+ NLS_INFO_COUNTRY = 0x0700,
63+ NLS_INFO_CODEPAGE = 0x0701,
64+ NLS_INFO_DECSEP = 0x0702,
65+ NLS_INFO_THOUSEP = 0x0703,
66+ NLS_INFO_DATEFMT = 0x0704,
67+ NLS_INFO_TIMEFMT = 0x0705,
68+ NLS_INFO_YESNO = 0x0706,
69+ NLS_INFO_CURREXAMPLE = 0x0707,
70+ NLS_MAKESURE = 0x0709,
71+
72+ NLS_ERR_FILEPATHTWICE = 0x0900,
73+ NLS_ERR_BADPATH = 0x0901,
74+ NLS_ERR_READFAIL = 0x0902,
75+ NLS_ERR_INVPARAM = 0x0903
76+};
77+
78+
79+static void nls_puts(enum NLS_STRINGS id) {
80+ puts(svarlang_strid(id));
81+}
82+
83+
84+static void nls_put(enum NLS_STRINGS id) {
85+ printf("%s", svarlang_strid(id));
86+}
87+
88+
89+static void crlf(void) {
90+ puts("");
91+}
92+
93+
3794 static void about(void) {
38- puts("localcfg ver " PVER " - locales configuration for DOS\n"
39- "Copyright (C) " PDATE " Mateusz Viste\n"
40- "\n"
41- "localcfg creates or edits a custom COUNTRY.SYS-like file with your preferences.\n"
42- "\n"
43- "usage: localcfg [COUNTRY.SYS] [options]\n"
44- "\n"
45- "options allow to configure country locales to your likening, as follows:\n"
46- " /country:XX indicates your country code is XX (1 for USA, 33 for France, etc)\n"
47- " /cp:XXX adapts country data for codepage XXX (example: '437')\n"
48- " /decim:X reconfigures the decimal symbol to be 'X'");
49- puts(" /thous:X reconfigures the thousands symbol to be 'X'\n"
50- " /datesep:X sets the date separator to 'X' (for example '/')\n"
51- " /datefmt:X sets the date format, can be: MDY, DMY or YMD\n"
52- " /timesep:X sets the time separator to 'X' (for example ':')\n"
53- " /timefmt:X sets the time format: 0=12h with AM/PM or 1=24h\n"
54- " /curr:XXX sets the currency to XXX (a string of 1 to 4 characters)\n"
55- " /currpos:X sets the currency symbol position to X, where X is either");
56- puts(" 0=currency precedes the value, 1=currency follows the value and\n"
57- " 2=currency replaces the decimal sign\n"
58- " /currspc:X space between the currency and the value (0=no, 1=yes)\n"
59- " /currprec:X currency's precision (number of decimal digits, 0..9)\n"
60- " /yesno:XY sets the 'Yes/No' letter to XY (default: YN)\n"
61- "\n"
62- "If COUNTRY.SYS location is not provided, then localcfg tries loading it\n"
63- "from %DOSDIR%\\CFG\\COUNTRY.SYS\n"
64- );
95+ printf("localcfg ");
96+ nls_put(NLS_HLP_VER);
97+ puts(" " PVER ", (C) " PDATE " Mateusz Viste");
98+ crlf();
99+ nls_puts(NLS_HLP_DESC);
100+ crlf();
101+ nls_puts(NLS_HLP_USAGE);
102+ crlf();
103+ nls_puts(NLS_HLP_OPTIONS);
104+ crlf();
105+ nls_puts(NLS_HLP_COUNTRY);
106+ nls_puts(NLS_HLP_CP);
107+ nls_puts(NLS_HLP_DECIM);
108+ nls_puts(NLS_HLP_THOUS);
109+ nls_puts(NLS_HLP_DATESEP);
110+ nls_puts(NLS_HLP_DATEFMT);
111+ nls_puts(NLS_HLP_TIMESEP);
112+ nls_puts(NLS_HLP_TIMEFMT);
113+ nls_puts(NLS_HLP_CURR);
114+ nls_puts(NLS_HLP_CURRPOS0);
115+ nls_puts(NLS_HLP_CURRPOS1);
116+ nls_puts(NLS_HLP_CURRPOS2);
117+ nls_puts(NLS_HLP_CURRSPC);
118+ nls_puts(NLS_HLP_CURRPREC);
119+ nls_puts(NLS_HLP_YESNO);
120+ crlf();
121+ nls_puts(NLS_HLP_INFOLOC1);
122+ nls_puts(NLS_HLP_INFOLOC2);
65123 }
66124
67125
@@ -303,16 +361,18 @@
303361 int x;
304362 static char fname[130];
305363
364+ svarlang_autoload("localcfg");
365+
306366 /* scan argv looking for the path to country.sys */
307367 for (x = 1; x < argc; x++) {
308368 if (argv[x][0] != '/') {
309369 if (fname[0] != 0) {
310- puts("ERROR: file path can be provided only once");
370+ nls_puts(NLS_ERR_FILEPATHTWICE);
311371 return(1);
312372 }
313373 /* */
314374 if (file_truename(fname, argv[x]) != 0) {
315- puts("ERROR: bad file path");
375+ nls_puts(NLS_ERR_BADPATH);
316376 return(1);
317377 }
318378 } else if (strcmp(argv[x], "/?") == 0) { /* is it /? */
@@ -326,7 +386,7 @@
326386
327387 x = country_read(&cntdata, fname);
328388 if (x != 0) {
329- printf("ERROR: failed to read the preference file [%d]\n", x);
389+ nls_puts(NLS_ERR_READFAIL);
330390 return(2);
331391 }
332392
@@ -337,23 +397,32 @@
337397 if (argv[x][0] != '/') continue; /* skip country.sys filename (processed earlier) */
338398 changedflag++;
339399 if (processarg(argv[x], &cntdata) != 0) {
340- puts("ERROR: invalid parameter syntax");
400+ nls_puts(NLS_ERR_INVPARAM);
341401 return(3);
342402 }
343403 }
344404
345- printf("Country intl code.....: %03d\n", cntdata.CTYINFO.id);
346- printf("Codepage..............: %d\n", cntdata.CTYINFO.codepage);
347- printf("Decimal separator.....: %c\n", cntdata.CTYINFO.decimal[0]);
348- printf("Thousands separator...: %c\n", cntdata.CTYINFO.thousands[0]);
349- printf("Date format...........: %s\n", datestring(&cntdata));
350- printf("Time format...........: %s\n", timestring(&cntdata));
351- printf("Yes/No letters........: %c/%c\n", cntdata.YESNO.yes[0], cntdata.YESNO.no[0]);
352- printf("Currency example......: %s\n", currencystring(&cntdata));
405+ nls_put(NLS_INFO_COUNTRY);
406+ printf(" %03d\r\n", cntdata.CTYINFO.id);
407+ nls_put(NLS_INFO_CODEPAGE);
408+ printf(" %d\r\n", cntdata.CTYINFO.codepage);
409+ nls_put(NLS_INFO_DECSEP);
410+ printf(" %c\r\n", cntdata.CTYINFO.decimal[0]);
411+ nls_put(NLS_INFO_THOUSEP);
412+ printf(" %c\r\n", cntdata.CTYINFO.thousands[0]);
413+ nls_put(NLS_INFO_DATEFMT);
414+ printf(" %s\r\n", datestring(&cntdata));
415+ nls_put(NLS_INFO_TIMEFMT);
416+ printf(" %s\r\n", timestring(&cntdata));
417+ nls_put(NLS_INFO_YESNO);
418+ printf(" %c/%c\r\n", cntdata.YESNO.yes[0], cntdata.YESNO.no[0]);
419+ nls_put(NLS_INFO_CURREXAMPLE);
420+ printf(" %s\r\n", currencystring(&cntdata));
353421
354- printf("\n"
355- "Make sure that your CONFIG.SYS contains this directive:\n"
356- "COUNTRY=%03d,%03d,%s\n\n", cntdata.CTYINFO.id, cntdata.CTYINFO.codepage, fname);
422+ crlf();
423+ nls_puts(NLS_MAKESURE);
424+ printf("COUNTRY=%03d,%03d,%s", cntdata.CTYINFO.id, cntdata.CTYINFO.codepage, fname);
425+ crlf();
357426
358427 /* if anything changed, write the new file */
359428 if (changedflag != 0) country_write(fname, &cntdata);
Show on old repository browser