LuaLibraries.wiki
changeset 867 30cc2f85c5e7
parent 798 30c5f1ebd552
child 868 0b400b3e05cc
equal deleted inserted replaced
866:e8d5c66477b7 867:30cc2f85c5e7
    23 
    23 
    24 ==== `loc(text)` ====
    24 ==== `loc(text)` ====
    25 
    25 
    26 Returns the localised string of `text` or, if it is not found, it returns `text`.
    26 Returns the localised string of `text` or, if it is not found, it returns `text`.
    27 
    27 
    28 
    28 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:
       
    29 
       
    30  * `text` _must_ be entirely a literal string
       
    31  * The text _must_ be enclosed in double quotes
       
    32  * You _must_ use the exact character sequence “`loc("`” to initiate the text, no spaces in between are permitted
       
    33 
       
    34 Valid example:
       
    35 <code language="lua">
       
    36 AddCaption(loc("Hello World"))  -- Displays “Hello World” translated into your language
       
    37 </code>
       
    38 
       
    39 These are all _incorrect_ usages of the `loc` function:
       
    40 <code language="lua">
       
    41 local l
       
    42 l = loc( "Hello World")    -- Contains space. This is valid Lua code but
       
    43 l = loc ("Hello World")    -- Contains space
       
    44 l = loc('Hello World')     -- Not double quotes
       
    45 local str = "Hello World"
       
    46 l = loc(str)   -- Not a literal string
       
    47 l = loc(str .. ", how are you?")   -- Only partially a literal string
       
    48 </code>
       
    49 
       
    50 Note these examples do _not_ violate Lua syntax, it is in your responsibility to follow the syntax rules listed above.
    29 
    51 
    30 == Utils ==
    52 == Utils ==
    31 
    53 
    32 This library includes miscellaneous functions to use, they are all independent of each other and can be used everywhere.
    54 This library includes miscellaneous functions to use, they are all independent of each other and can be used everywhere.
    33 
    55