1,7 → 1,11 |
|
|
SVARLANG.LIB - THE SVARDOS TRANSLATION C LIBRARY |
|
Copyright (C) 2021-2022 Mateusz Viste |
|
|
|
SvarLANG is a library and tooling for enabling SvarDOS applications to easily |
support multiple languages. |
|
29,33 → 33,24 |
* DEFLANG.C - the default translations that will be embedded into the program |
|
Then, DEFLANG.C must be compiled and linked to your program along with |
SVARLNGx.LIB. From there, you will be able to use the following calls: |
SVARLNGx.LIB. From there you will be able to use SvarLANG calls, typically: |
|
/* loads translations for program PROGNAME, language LANG, in the path NLSPATH. |
* returns 0 on success. */ |
int svarlang_load(const char *progname, const char *lang, const char *nlspath); |
svarlang_load("myprogram", "pl", "."); /* load .\myprogram.lng */ |
puts(svarlang_str(2, 0)); /* display the string with id 2.0 */ |
|
/* same as svarlang_load(), but relies on getenv() to pull LANG and NLSPATH. */ |
int svarlang_autoload(const char *progname); |
Read svarlang.h for more information about available functions. |
|
/* Returns a pointer to the string "id". Does not require svalang_load() to be |
* executed, but then it will only return the reference language strings. |
* a string id is the concatenation of the CATS-style identifiers, for example |
* string 1,0 becomes 0x0100, string 2.10 is 0x020A, etc. */ |
const char *svarlang_strid(unsigned short id); |
|
/* a convenience definition to fetch strings by their CATS-style pairs instead |
* of the 16-bit id. */ |
#define svarlang_str(x, y) svarlang_strid((x << 8) | y) |
|
|
### ENVIRONMENT ### |
|
All translations files should be placed in the %NLSPATH% directory and should |
be named the same as the program's name, with the LNG extension (for example |
"INSTALL.LNG" if the program is named "INSTALL"). |
The program translation file should be named "PROGNAME.LNG", where PROGNAME |
is the program's name. This file should be placed in a well-known location, |
typically the program's own directory. An exception are SvarDOS "CORE" programs |
that store their translation files in a directory pointed out by %NLSPATH%. |
|
The %LANG% environment variable defines what language should be loaded. |
The %LANG% environment variable usually defines what language should be loaded, |
albeit the program can just as well provide its own controls for language |
selection and pass this information to svarlang_load() accordingly. |
|
|
### WHY IS IT BETTER THAN CATS? ### |