Import intllib 0.1.0
[minetest_tutorial_subgame.git] / mods / intllib / README.txt
blob37f5c480df0c1e8aa06c8f71f61eac0725d2c951
2 Internationalization Lib for Minetest
3 By Diego Martínez (a.k.a. "Kaeza").
4 Released as WTFPL.
6 This mod is an attempt at providing internationalization support for mods
7 (something Minetest currently lacks).
9 How do I use it?
10 In order to enable it for your mod, copy the following code snippet and paste
11 it at the beginning of your source file(s):
13   -- Boilerplate to support localized strings if intllib mod is installed.
14   local S
15   if intllib then
16     S = intllib.Getter()
17   else
18     S = function(s) return s end
19   end
21 You will also need to optionally depend on intllib, to do so add "intllib?" to
22 a empty line in your depends.txt. Also note that if intllib is not installed,
23 the S() function is defined so it returns the string unchanged. This is done
24 so you don't have to sprinkle tons of 'if's (or similar constructs) to check
25 if the lib is actually installed.
27 Next, for each "translatable" string in your sources, use the S() function
28 (defined in the snippet) to return the translated string. For example:
30   minetest.register_node("mymod:mynode", {
31     description = S("My Fabulous Node"),
32     <...>
33   })
35 Then, you create a `locale' directory inside your mod directory, with files
36 named after the two-letter ISO Language Code of the languages you want to
37 support. Here's an example for a Spanish locale file (`es.txt'):
39   # Lines beginning with a pound sign are comments and are effectively ignored
40   # by the reader. Note that comments only span until the end of the line;
41   # there's no support for multiline comments.
42   Hello, World! = Hola, Mundo!
43   String with\nnewlines = Cadena con\nsaltos de linea
44   String with an \= equals sign = Cadena con un signo de \= igualdad
46 Since there's currently no portable way to detect the language, this library
47 tries several alternatives, and uses the first one found:
48   - `language' setting in `minetest.conf'
49   - `LANG' environment variable (this is always set on Unix-like OSes).
50   - Default of "en".
51 Note that in any case only up to the first two characters are used, so for
52 example, the settings "de_DE.UTF-8", "de_DE", and "de" are all equal.
53 Windows users have no `LANG' environment variable by default. To add it, do
54 the following:
55   - Click Start->Settings->Control Panel.
56   - Start the "System" applet.
57   - Click on the "Advanced" tab.
58   - Click on the "Environment variables" button
59   - Click "New".
60   - Type "LANG" (without quotes) as name and the language code as value.
61   - Click OK until all dialogs are closed.
62 Alternatively for all platforms, if you don't want to modify system settings,
63 you may add the following line to your `minetest.conf' file:
64   language = <language code>
66 Also note that there are some problems with using accented, and in general
67 non-latin characters in strings. Until a fix is found, please limit yourself
68 to using only US-ASCII characters.
70 Thanks for reading up to this point.
71 Should you have any comments/suggestions, please post them in the forum topic.
73 Let there be translated texts! :P
75 Yours Truly,
76 Kaeza