Subversion Repositories SvarDOS

Rev

Rev 620 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 620 Rev 814
Line 1... Line 1...
1
 
1
 
-
 
2
 
2
              SVARLANG.LIB - THE SVARDOS TRANSLATION C LIBRARY
3
              SVARLANG.LIB - THE SVARDOS TRANSLATION C LIBRARY
3
 
4
 
-
 
5
                   Copyright (C) 2021-2022 Mateusz Viste
-
 
6
 
-
 
7
 
4
 
8
 
5
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
6
support multiple languages.
10
support multiple languages.
7
 
11
 
8
 
12
 
Line 27... Line 31...
27
 
31
 
28
 * OUT.LNG   - the binary file that contains all translations
32
 * OUT.LNG   - the binary file that contains all translations
29
 * 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
30
 
34
 
31
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
32
SVARLNGx.LIB. From there, you will be able to use the following calls:
36
SVARLNGx.LIB. From there you will be able to use SvarLANG calls, typically:
33
 
37
 
34
/* loads translations for program PROGNAME, language LANG, in the path NLSPATH.
-
 
35
 * returns 0 on success. */
-
 
36
int svarlang_load(const char *progname, const char *lang, const char *nlspath);
38
  svarlang_load("myprogram", "pl", "."); /* load .\myprogram.lng */
37
 
-
 
38
/* same as svarlang_load(), but relies on getenv() to pull LANG and NLSPATH. */
39
  puts(svarlang_str(2, 0));              /* display the string with id 2.0 */
39
int svarlang_autoload(const char *progname);
-
 
40
 
-
 
41
/* Returns a pointer to the string "id". Does not require svalang_load() to be
-
 
42
 * executed, but then it will only return the reference language strings.
-
 
43
 * a string id is the concatenation of the CATS-style identifiers, for example
-
 
44
 * string 1,0 becomes 0x0100, string 2.10 is 0x020A, etc. */
-
 
45
const char *svarlang_strid(unsigned short id);
-
 
46
 
-
 
47
/* a convenience definition to fetch strings by their CATS-style pairs instead
-
 
48
 * of the 16-bit id. */
-
 
49
#define svarlang_str(x, y) svarlang_strid((x << 8) | y)
-
 
50
 
40
 
-
 
41
Read svarlang.h for more information about available functions.
51
 
42
 
52
### ENVIRONMENT ###
-
 
53
 
43
 
54
All translations files should be placed in the %NLSPATH% directory and should
-
 
55
be named the same as the program's name, with the LNG extension (for example
-
 
56
"INSTALL.LNG" if the program is named "INSTALL").
44
### ENVIRONMENT ###
57
 
45
 
-
 
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%.
-
 
50
 
58
The %LANG% environment variable defines what language should be loaded.
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.
59
 
54
 
60
 
55
 
61
### WHY IS IT BETTER THAN CATS? ###
56
### WHY IS IT BETTER THAN CATS? ###
62
 
57
 
63
The CATS library is heavier and slower, as it embeds a text-file parser.
58
The CATS library is heavier and slower, as it embeds a text-file parser.