微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

NativeLang NativeScript 国际化插件

程序名称:NativeLang

授权协议: MIT

操作系统: Android

开发语言: JavaScript

NativeLang 介绍

NativeLang 是 NativeScript 的国际化插件

创建文件

├── app <----------------- run npm install from here
│   ├── App_Resources
│   │   └── ...
│   ├── tns_modules
│   │   └── ...
│   ├── app.css
│   ├── app.js
│   ├── main-page.js
│   ├── main-page.xml
│   ├── main-view-model.js
│   ├── node_modules
│   │   └── nativelang <-- The install will place the module's code here
│   │       └── ...
│   └── package.json <---- The install will register “nativelang" as a dependency here
└── platforms
    ├── android
    │   └── res
    │       ├── values <---------- English
    │       |   └── strings.xml
    │       ├── values-es <------- Spanish
    │       |   └── strings.xml
    │       └── values-fr <------- Fransih
    │           └── strings.xml
    └── ios

文件

<!-- platforms/android/res/values/strings.xml -->
<?xml version="1.0" encoding="UTF-8"?>
<resources>
    <string name="app_name" formatted="false">Example 1</string>
    <string name="other" formatted="false">Other</string>
    ... More strings
</resources>
<!-- platforms/android/res/values-es/strings.xml -->
<?xml version="1.0" encoding="UTF-8"?>
<resources>
    <string name="app_name" formatted="false">Ejemplo 1</string>
    <string name="other" formatted="false">Otro</string>
    ... Y mas cadenas
</resources>

使用:

app/app.js

GLOBAL.L = require( "./node_modules/nativelang/lib" )();

xml

<Label  text={{ L('other')}} />

NativeLang 官网

https://github.com/alejonext/NativeLang

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐