CLI to manage internationalizing your Titanium app

Titanium i18n

Titanium i18n (ti-i18n) is both a pluggable TitaniumCLI 3.2+ command and stand-alone CLI for managing your app's internationalization. It replaces the soon to be deprecated alloy extract-i18nand works on both Alloyand Classic projects.

1. Get it

ti-i18nis built on Node.js. Once you have Node.js installed you can use the included NPM package manager to install ti-i18nvia the following command:

sudo npm install -g ti-i18n

Optionally plug as Titanium CLI 3.2.0 command

If you already run the upcoming Titanium CLI 3.2.0, you can let ti-i18nplug itself as a command under the Titanium CLI:

ti-i18n plug

Once, you've done this. The following (note the -) do exactly the same:

ti-i18n extract
ti i18n extract

ti-i18nwill be further developped to be a worthy command, listen to the global flags like --no-colorsand read any relevant defaults from the CLI config. Use ti-i18n pluggedand ti-i18n unplugto check if ti-i18nis plugged or unplug.

Or use it as a module

You can also use ti-18nas an dependency of your NodeJS project. The same options apply, just use the full names and make sure options like --project-dirare camel-cased to projectDir.

var i18n = require('ti-i18n');
    language: 'nl',
    apply: true

2. Use it


As demonstrated by the test on the files in test/source, ti-i18nis able to extract i18n strings from XML, TSS and JS source code. Just don't use composed strings like L('error_' + code);.

By default ti-i18nscans the i18ndirectory for languages and reads and writes to all of them. You can choose a specific language by passing it as the first argument after the extractcommand.

Use the -aor --applyflag to actually append the missing strings to the files. In both cases, ti-i18nwill display a table with the exact changes (to be) made.

Usage: extract [options]
Example: ti-i18n extract -a -l nl
    -a, --apply               append to the strings.xml files (default: no)
    -d, --project-dir <path>  Project directory (default: current)
    -l, --language <ln>       single language to compare with and write to (default: all)


The sync command makes sure all languages have the same strings. If a file doesn't have a string present in one of the other languages, it will be appended to it.

Use the -aor --applyflag to actually append the missing strings to the files. In both cases, ti-i18nwill display a table with the exact changes (to be) made.

Usage: sync [options]
Example: ti-i18n sync -a
    -a, --apply               append to the strings.xml files (default: no)
    -d, --project-dir <path>  Project directory (default: current)


Once you've had the strings translated, you can merge the translated XML with the one in your project. Existing string values will be updated and new strings added but if during translation your strings.xml file has grown, the new ones will be preserved.

Usage: merge [options]
Example: ti-i18n merge -s ~/translated.xml -l nl -a
    -a, --apply               overwrite the strings.xml file (default: no)
    -d, --project-dir <path>  Project directory (default: current)
    -s, --source <path>       Source strings.xml file to merge from
    -l, --language <ln>       language to compare with and merge to


You can sort the strings in all language files of a project using the sortcommand.

Usage: sort [options]
Example: ti-i18n sort
    -d, --project-dir <path>  Project directory (default: current)

Global options

-h, --helpbothoutput usage information
-v, --versionstand-aloneoutput the version number (as a hook, this will output the Titanium CLI version)


The testfolder contains a single unit-test you can use, e.g. with mocha:

sudo npm install -g mocha
mocha test/test.js


  • Rewrite extractto search through XML, TSS(JSON) and JS(AST).
  • Option to remove second hint-argument from Land use it in strings.xml.
  • Add validateto validate strings.xmlfor UTF-8, CDATA, duplicates etc.
  • Add cleanto comment out any strings not found in source.
  • Add mergeto merge translated file back into project.
  • Add peerto make sure all language have same strings.
  • Add nameto create/update XML for internationalized app names.


Copyright 2013 Fokke Zandbergen

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at


Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
See the License for the specific language governing permissions and
limitations under the License.







  • (JavaScript) Array的tips

    1. Array.prototype.push() 像数组一样使用对象: 尽管 obj 不是数组,但是 push 方法成功地使 obj 的 length 属性增长了,就像我们处理一个实际的数...

    2 年前
  • 高频数据交换下Flutter与ReactNative的对比

    (标题图片来自网络,侵删) 后端使用go写的socketio服务模拟期货行情数据,每10ms推送10条行情数据 ReactNative已经尽力优化了。 Flutter由于没fluttersock...

    2 年前
  • 高德地图---获取用户地理位置Geolocation

    一、前提 二、js实现逻辑功能创建地图,获取用户地理位置(3种方式)1) 地图初始化加载定位到当前城市。 2) 浏览器定位。 3) IP定位获取当前城市信息ps: 需求需要定位到具体的位置,...

    2 个月前
  • 项目代码的格式化统一配置 Prettier & ESLint

    以前没时间过eslint,每次项目vscode 编辑器的eslint插件就关掉eslint,老项目都没注意过相关的代码规范,这次新项目加入进去实践下! Question 1. 三个插件功自动有...

    2 年前
  • 面试官:请你在React中引入Vue3的@vue/reactivity,实现响应式。

    前言 React的状态管理是一个缤纷繁杂的大世界,光我知道的就不下数十种,其中有最出名immutable阵营的redux,有mutable阵营的mobx,reacteasystate,在hooks诞生...

    4 个月前
  • 随着nativescript Appium测试应用程序

    Zakaria Acharkiuser70192(https://stackoverflow.com/users/4281779/zakariaacharki)提出了一个问题:Testing Nati...

    2 年前
  • 阅读 is-generator-function 源码

    (https://img.javascriptcn.com/152091d995a0b72de8b8d6aa8c0c768f) 从正则表达式 (https://img.javascriptc...

    1 年前
  • 问道Angular——APP_INITIALIZER

    概述   有时需要在加载应用之前运行代码,有时希望暂停应用初始化,直到完成某些限制之后再执行。APPINITIALIZER令牌可以完成这项操作。 APPINITIALIZER是一个函数,在应用改程...

    2 年前
  • 针对angular分页插件tm.pagination二次触发问题三种解决方案

    今天在开发个人博客的时候,需要对列表进行分页操作,因为整体使用的是AngularJs,所以分页插件也就选择了AngularJs pagination.js。可是在调试的时候发现的非常恶心的事情,在加载...

    8 个月前
  • 重置setTimeout

    Marcel KorpelJason(https://stackoverflow.com/users/258127/marcelkorpel)提出了一个问题:Resetting a setTimeou...

    2 年前


扫码加入 JavaScript 社区