Subversion Repositories SvarDOS

Rev

Rev 969 | Rev 1244 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 969 Rev 1114
1
 
1
 
2
 
2
 
3
              SVARLANG.LIB - THE SVARDOS TRANSLATION C LIBRARY
3
              SVARLANG.LIB - THE SVARDOS TRANSLATION C LIBRARY
4
 
4
 
5
                   Copyright (C) 2021-2022 Mateusz Viste
5
                   Copyright (C) 2021-2022 Mateusz Viste
6
 
6
 
7
 
7
 
8
 
8
 
9
SvarLANG is a library and tooling for enabling SvarDOS applications to easily
9
SvarLANG is a library and tooling for enabling SvarDOS applications to easily
10
support multiple languages.
10
support multiple languages.
11
 
11
 
12
 
12
 
13
### PREPARING TRANSLATION FILES ###
13
### PREPARING TRANSLATION FILES ###
14
 
14
 
15
The translation files must be CATS-style text files in the usual format:
15
The translation files must be CATS-style text files in the usual format:
16
 
16
 
17
1.1:Hello, World!
17
1.1:Hello, World!
18
1.2:Help screen
18
1.2:Help screen
19
2.0:Type /? for more options
19
2.0:Type /? for more options
20
 
20
 
21
The files must be named as EN.TXT, DE.TXT, FR.TXT, etc. Then, they must be
21
The files must be named as EN.TXT, DE.TXT, FR.TXT, etc. Then, they must be
22
"compiled" into SvarLANG's binary format using the TLUMACZ tool:
22
"compiled" into SvarLANG's binary format using the TLUMACZ tool:
23
 
23
 
24
tlumacz en fr pl (...)
24
tlumacz en fr pl (...)
25
 
25
 
26
The first language provided in the command line is the reference language and
26
The first language provided in the command line is the reference language and
27
is used both as the default (embedded in the application) language, as well as
27
is used both as the default (embedded in the application) language, as well as
28
to substitute messages missing in other languages.
28
to substitute messages missing in other languages.
29
 
29
 
30
TLUMACZ computes two files:
30
TLUMACZ computes two files:
31
 
31
 
32
 * OUT.LNG   - the binary file that contains all translations
32
 * OUT.LNG   - the binary file that contains all translations
33
 * DEFLANG.C - the default translations that will be embedded into the program
33
 * DEFLANG.C - the default translations that will be embedded into the program
34
 
34
 
35
Then, DEFLANG.C must be compiled and linked to your program along with
35
Then, DEFLANG.C must be compiled and linked to your program along with
36
SVARLNGx.LIB. From there you will be able to use SvarLANG calls, typically:
36
SVARLNGx.LIB. From there you will be able to use SvarLANG calls, typically:
37
 
37
 
38
  svarlang_load("myprogram", "pl", "."); /* load .\myprogram.lng */
38
  svarlang_load("myprogram", "pl", "."); /* load .\myprogram.lng */
39
  puts(svarlang_str(2, 0));              /* display the string with id 2.0 */
39
  puts(svarlang_str(2, 0));              /* display the string with id 2.0 */
40
 
40
 
41
Read svarlang.h for more information about available functions.
41
Read svarlang.h for more information about available functions.
42
 
42
 
43
 
43
 
-
 
44
### DIRTY STRINGS ###
-
 
45
 
-
 
46
In the CATS-style source translation, lines may be prefixed with a '?' sign:
-
 
47
 
-
 
48
?1.1:Hello, World!
-
 
49
 
-
 
50
Such string is used by tlumacz like any other, but it is also reported on the
-
 
51
command-line with a warning about the line being "dirty" (that is, requiring
-
 
52
to be reviewed by a translator).
-
 
53
 
-
 
54
 
44
### ENVIRONMENT ###
55
### ENVIRONMENT ###
45
 
56
 
46
The program translation file should be named "PROGNAME.LNG", where PROGNAME
57
The program translation file should be named "PROGNAME.LNG", where PROGNAME
47
is the program's name. This file should be placed in a well-known location,
58
is the program's name. This file should be placed in a well-known location,
48
typically the program's own directory. An exception are SvarDOS "CORE" programs
59
typically the program's own directory. An exception are SvarDOS "CORE" programs
49
that store their translation files in a directory pointed out by %NLSPATH%.
60
that store their translation files in a directory pointed out by %NLSPATH%.
50
 
61
 
51
The %LANG% environment variable usually defines what language should be loaded,
62
The %LANG% environment variable usually defines what language should be loaded,
52
albeit the program can just as well provide its own controls for language
63
albeit the program can just as well provide its own controls for language
53
selection and pass this information to svarlang_load() accordingly.
64
selection and pass this information to svarlang_load() accordingly.
54
 
65
 
55
 
66
 
56
### WHY IS IT BETTER THAN CATS? ###
67
### WHY IS IT BETTER THAN CATS? ###
57
 
68
 
58
The CATS library is heavier and slower, as it embeds a text-file parser.
69
The CATS library is heavier and slower, as it embeds a text-file parser.
59
Translations also take more disk space since each file is in a separate file
70
Translations also take more disk space since each file is in a separate file
60
leading to cluster waste. Finally, CATS requires default strings to be part of
71
leading to cluster waste. Finally, CATS requires default strings to be part of
61
the application's source code, while SvarLANG keeps all strings in TXT files
72
the application's source code, while SvarLANG keeps all strings in TXT files
62
and embedds the default one inside the application in an automated way at
73
and embedds the default one inside the application in an automated way at
63
compile time.
74
compile time.
64
 
75
 
65
There is also a licensing issue: CATS/Kitten libraries are published under the
76
There is also a licensing issue: CATS/Kitten libraries are published under the
66
terms of a viral license. SvarLANG, on the other hand, is published under a
77
terms of a viral license. SvarLANG, on the other hand, is published under a
67
truly free, liberal license (MIT).
78
truly free, liberal license (MIT).
68
 
79
 
69
 
80
 
70
======================================================================= EOF ===
81
======================================================================= EOF ===
71
 
82