Subversion Repositories SvarDOS

Rev

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

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