Subversion Repositories SvarDOS

Rev

Rev 1114 | Rev 1246 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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