/xlsx2lua-language

Lua Language Package

Primary LanguagePython

xls2lua 基于Python3.X使用 (将xlsx数据文件转化为lua脚本,作为游戏语言包使用)

use python xlrd

(使用python xlrd模块)

(如果你在使用Lua语言,将数据写进Lua文件是最方便的做法。这个脚本将帮助你将数据xls、xlsx文件转化为lua文件,这样你就可以更好的工作了。)

Excute Example (举例执行命令)

python ./xls2lua.py

NOTICE:(注意点)

(sheet名以"OUT_"开头的才会被识别转换,否则将被忽略)
(仿照词典,至少两列,一列为Key值,一列为Value值)
(可以给Value字符串传递参数,符合Lua string.format()函数使用规范,比如%s表示替换字符串,%d,%f等等)
(除前两列外其他不会写入Lua文件当中,所以可以随便注释)

Lua script (生成后的Lua文件示例)

-- This file is generated by program!
-- Don't change it manaully.
-- Author: chuxiang9007@163.com  NormanYang
-- Source file: LangManager.xlsx
-- Created at: Tue Dec 22 07:15:29 2015


LangManager = {}
local this = LangManager

this["TxtTitle1001"] = "创建磁卡是不可借此撒"
this["TxtTitle1005"] = "创建磁卡是不可借此撒"
this["TxtTitle1007"] = "创建磁卡是不可借此撒"
this["TxtTitle1003"] = "创建磁卡是不可借此撒"
this["TxtTitle1006"] = "创建磁卡是不可借此撒"
this["TxtTitle1002"] = "创建磁卡是不可借此撒"
this["TxtTitle1004"] = "创建磁卡是不可借此撒"
this["TxtTitle1000"] = "创建磁卡是不可借此撒  Start"
this["TxtTitle1008"] = "创建磁卡是不可借此撒  End"
this["TxtUI1013"] = "是什么东东"
this["TxtUI1003"] = "是什么东东"
this["TxtUI1011"] = "是什么东东"
this["TxtUI1006"] = "是什么东东"
this["TxtUI1008"] = "是什么东东"
this["TxtUI1009"] = "是什么东东"
this["TxtUI1000"] = "是什么东东 Start"
this["TxtUI1005"] = "是什么东东"
this["TxtUI1015"] = "是什么东东"
this["TxtUI1004"] = "是什么东东"
this["TxtUI1007"] = "是什么东东"
this["TxtUI1016"] = "是什么东东 End"
this["TxtUI1014"] = "是什么东东"
this["TxtUI1012"] = "是什么东东"
this["TxtUI1010"] = "是什么东东 Start"
this["TxtUI1002"] = "是什么东东"
this["TxtUI1001"] = "是什么东东"
this["TxtStory1005"] = "二十年都是梦啊 "
this["TxtStory1004"] = "二十年都是梦啊 "
this["TxtStory1001"] = "二十年都是梦啊 "
this["TxtStory1003"] = "二十年都是梦啊 "
this["TxtStory1000"] = "二十年%s都是%d梦啊 Start"
this["TxtStory1002"] = "二十年都是梦啊 "
this["TxtStory1007"] = "二十年都是梦啊 End"
this["TxtStory1006"] = "二十年都是梦啊 "

function LangManager.GetText(key, ...)
	return string.format(this[key], ...)
end

How to use lua with data. (如何使用生成的lua数据)

print(LangManager.GetText("TxtStory1000","12", 4343))

The console will print "二十年12都是4343梦啊 Start"