Advertisement
christophedlr

translate

Jul 22nd, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.69 KB | None | 0 0
  1. -- TranslateAPI program developed by Christophe Daloz - De Los rios
  2. -- License: http://cecill.info/licences/Licence_CECILL_V2-en.txt
  3. -- Version: 1.0
  4. --
  5. -- TranslateAPI  is an API for translate LUA programs in different languages
  6.  
  7. local table_translation = {}
  8.  
  9. function open(filename)
  10.     if fs.exists(filename) then
  11.         print("OK")
  12.         local file = fs.open(filename, "r")
  13.         table_translation = textutils.unserialize( file.readAll() )
  14.         file.close()
  15.         return true
  16.     else
  17.         print("The "..filename.." file is not exists")
  18.         return false
  19.     end
  20. end
  21.  
  22. function tr(text)
  23.     if table_translation[text] then
  24.         return table_translation[text].text
  25.     end
  26.  
  27.     return "Undefined "..text.." translation"
  28. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement