Subversion Repositories SvarDOS

Rev

Details | 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
 
814 mateusz.vi 5
                   Copyright (C) 2021-2022 Mateusz Viste
597 mateuszvis 6
 
814 mateusz.vi 7
 
8
 
599 mateuszvis 9
SvarLANG is a library and tooling for enabling SvarDOS applications to easily
10
support multiple languages.
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
 
44
### ENVIRONMENT ###
45
 
814 mateusz.vi 46
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,
48
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%.
599 mateuszvis 50
 
814 mateusz.vi 51
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
53
selection and pass this information to svarlang_load() accordingly.
599 mateuszvis 54
 
55
 
56
### WHY IS IT BETTER THAN CATS? ###
57
 
58
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
60
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
62
and embedds the default one inside the application in an automated way at
63
compile time.
64
 
620 mateuszvis 65
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
67
truly free, liberal license (MIT).
599 mateuszvis 68
 
620 mateuszvis 69
 
599 mateuszvis 70
======================================================================= EOF ===