Giter VIP home page Giter VIP logo

xlstoxml's Introduction

将 APP 开发多语言表格生成 Android string.xml ,以及 iOS Localizable.strings 的脚本

多语言 xls 生成 Android xml /iOS Localizable.strings

2018.10.25 新增支持将新增多语言直接写入 iOS 或 Android 项目的多语言文件

1.使用前准备

  • 安装 Python 3(最新版本是3.65)
  • 安装 Python Package ---- xlrd (命令行:pip install xlrd)
  • 简单处理多语言表格:插入一列至表格的首列,并对对应的 string 命名 id。(相当于提前给字符指定 Android 中的 R.id.... 或者 iOS当中的 key)

2.常规使用

cd 到 start.py 所在文件夹,并将多语言 xls 表格复制到同一文件夹下。 在本文件夹下运行 python start.py -f xxx.xls -t XXX (xxx.xls 为多语言表格名称加后缀,XXX 为 生成的 strings.xml以及 Localizable.strings 所在文件夹(python start.py -f xxx.xls -t . 表示 生成到当前脚本文件夹)。 脚本运行完成后悔生成两个文件,Android 的 string.xml 与 iOS 的 Localizable.strings,多语言按照语种分类,都在同一个文件内,手动复制到项目中对应语种的文件内即可。

3.直接向项目中写入 Android 多语言 strings.xml 或 iOS 的 Localizable.strings(不需手动复制)

请先完成 使用前准备

然后检查表格第一行的国家代码,如果 写入 Android 项目的话,表格**家代码要分别与 res 文件夹下 values-xx 中的 xx 一致,如果是英文,则直接写 en ,对应 res 文件夹下的英文文件夹 values。如果是 iOS 项目,则表格**家代码要分别与 Localization 下的 xx.lproj 中的 xx 保持一致。

确认代码无误后

Android 在脚本所在文件夹下运行 python start.py -f xxx/xxx.xls -t xxx/xxx/res -w 1,其中 xxx/xxx.xls 为多语言表格路径,xxx/xxx/res 为 Android res 文件夹的路径。

iOS 在脚本所在文件夹下运行 python start.py -f xxx/xxx.xls -t xxx/xxx/Localization -w 0,其中 xxx/xxx.xls 为多语言表格路径,xxx/xxx/Localization 为 iOS Localization 文件夹的路径。

脚本运行完毕,写入即完成

备注:对于项目中没有的多语言语种,而表格中有,会新建对应的多语言文件夹与文件

xlstoxml's People

Contributors

caelanyang avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.