diff options
author | ShadowNinja <noreply@gmail.com> | 2013-10-29 11:19:35 -0400 |
---|---|---|
committer | ShadowNinja <noreply@gmail.com> | 2013-10-29 11:19:35 -0400 |
commit | af31d71d1a9ffd6d1373b2714bcf025c63afaaee (patch) | |
tree | e627ba33a5673a1a298a592b6e201fc6582cfbbc /README.txt | |
parent | 5de9bcea76f851e64cfb1307bc3d321642cb5be2 (diff) |
Use optional dependencies to only load once and re-add support for escapes
Diffstat (limited to 'README.txt')
-rw-r--r-- | README.txt | 38 |
1 files changed, 9 insertions, 29 deletions
@@ -12,20 +12,17 @@ it at the beginning of your source file(s): -- Boilerplate to support localized strings if intllib mod is installed. local S - if (minetest.get_modpath("intllib")) then - dofile(minetest.get_modpath("intllib").."/intllib.lua") - S = intllib.Getter(minetest.get_current_modname()) + if intllib then + S = intllib.Getter() else - S = function ( s ) return s end + S = function(s) return s end end -Note that by using this snippet, you don't need to depend on `intllib'. In -fact, the mod's `init.lua' is a no-op; you need to explicitly execute intllib's -`intllib.lua' file. -Also note that if the intllib "mod" is not installed, the S() function is -defined so it returns the string unchanged. This is done so you don't have to -sprinkle tons of `if's (or similar constructs) to check if the lib is actually -installed. +You will also need to optionally depend on intllib, to do so add "intllib?" to +a empty line in your depends.txt. Also note that if intllib is not installed, +the S() function is defined so it returns the string unchanged. This is done +so you don't have to sprinkle tons of 'if's (or similar constructs) to check +if the lib is actually installed. Next, for each "translatable" string in your sources, use the S() function (defined in the snippet) to return the translated string. For example: @@ -42,9 +39,8 @@ support. Here's an example for a Spanish locale file (`es.txt'): # Lines beginning with a pound sign are comments and are effectively ignored # by the reader. Note that comments only span until the end of the line; # there's no support for multiline comments. - Blank lines not containing an equals sign are also ignored. Hello, World! = Hola, Mundo! - String with\nnewlines and \ttabs = Cadena con\nsaltos de linea y\ttabuladores + String with\nnewlines = Cadena con\nsaltos de linea String with an \= equals sign = Cadena con un signo de \= igualdad Since there's currently no portable way to detect the language, this library @@ -71,22 +67,6 @@ Also note that there are some problems with using accented, and in general non-latin characters in strings. Until a fix is found, please limit yourself to using only US-ASCII characters. -Frequently Asked Questions --------------------------- -Q: Were you bored when you did this? -A: Yes. - -Q: Why are my texts are not translated? -A: RTFM...or ask in the topic 8-----) - -Q: How come the README is bigger than the actual code? -A: Because I'm adding silly unfunny questions here...and because there are - some users that are too lazy to understand how the code works, so I have - to document things. - -Q: I don't like this sh*t! -A: That's not a question. - Thanks for reading up to this point. Should you have any comments/suggestions, please post them in the forum topic. |