LuaLibraries: Explain proper usage of loc()
authorWuzzy
Sat, 09 Apr 2016 20:28:52 +0100
changeset 867 30cc2f85c5e7
parent 866 e8d5c66477b7
child 868 0b400b3e05cc
LuaLibraries: Explain proper usage of loc()
LuaLibraries.wiki
--- a/LuaLibraries.wiki	Sat Apr 09 13:47:49 2016 +0100
+++ b/LuaLibraries.wiki	Sat Apr 09 20:28:52 2016 +0100
@@ -25,7 +25,29 @@
 
 Returns the localised string of `text` or, if it is not found, it returns `text`.
 
+In order for your text to be taken by the string collection tools (so the string becomes available for translation), you have to follow a few simple syntax rules:
 
+ * `text` _must_ be entirely a literal string
+ * The text _must_ be enclosed in double quotes
+ * You _must_ use the exact character sequence “`loc("`” to initiate the text, no spaces in between are permitted
+
+Valid example:
+<code language="lua">
+AddCaption(loc("Hello World"))  -- Displays “Hello World” translated into your language
+</code>
+
+These are all _incorrect_ usages of the `loc` function:
+<code language="lua">
+local l
+l = loc( "Hello World")    -- Contains space. This is valid Lua code but
+l = loc ("Hello World")    -- Contains space
+l = loc('Hello World')     -- Not double quotes
+local str = "Hello World"
+l = loc(str)   -- Not a literal string
+l = loc(str .. ", how are you?")   -- Only partially a literal string
+</code>
+
+Note these examples do _not_ violate Lua syntax, it is in your responsibility to follow the syntax rules listed above.
 
 == Utils ==