Comparing version 1.1.6 to 1.2.0
{ | ||
"name": "ltsx", | ||
"version": "1.1.6", | ||
"version": "1.2.0", | ||
"description": "Localization module (marked with WeChat's mini-program supported)", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
# ltsx | ||
Localization module (marked with WeChat's mini-program supported) | ||
# Note | ||
Tested on macOS only. When you execute `npm --prefix ...` command as shown below on other platforms, it **might** has problem, or none at all. | ||
# Install | ||
@@ -8,2 +12,3 @@ | ||
Import into your source code by | ||
@@ -20,15 +25,15 @@ | ||
See [docs](https://abzico.github.io/lts). | ||
See [docs](https://abzico.github.io/lts) and look on the right sidebar. | ||
# Make It Works with WeChat's Mini-program | ||
# How to Use with WeChat's mini-program? | ||
Change directory to the root of your WeChat's mini-program project. | ||
Install this module via `npm install --save ltsx`. | ||
Install this module via `npm install --save ltsx`. No worry about existence of `node_modules` directory. Mini-program IDE has built-in ability to ignore it both while developing, and submitting. We can leave such directory as it is if you like. | ||
Execute `npm --prefix node_modules/ltsx run wechat-mp -- $PWD/src/wsx/` in which path argument can be any depends on your need. | ||
Execute `npm --prefix node_modules/ltsx run wechat-mp -- $PWD/src/wxs/` in which path argument **can be** any depends on your need. | ||
> Notice that we use `$PWD` to get the root directory of your WeChat's mini-program. This is because current directory of such executing command is still at `node_modules/ltsx`. | ||
Then modify `./src/wsx/defs.wxs` for your pre-defined localized text that will be used throughout the application life cycle. | ||
Then modify `./src/wxs/ltsx/defs.wxs` for your pre-defined localized text that will be used throughout the application life cycle. | ||
Example of its content is as follows. | ||
@@ -49,13 +54,13 @@ | ||
> As .wxs script file was meant to be used in non-dynamic way thus s | ||
Then inside your .wxml file, you would have something like this. | ||
Then inside your .wxml file, you do it like this. | ||
> Path is relative. So it depends on which source file you try to include `ltsx` to work with your code. Modify it accordingly. | ||
```html | ||
<wxs src="./src/wsx/ltsx.wxs" module="ltsx" /> | ||
<wxs src="./src/wsx/const-lang.wxs" module="langs" /> | ||
<wxs src="./src/wxs/ltsx/ltsx.wxs" module="ltsx" /> | ||
<wxs src="./src/wxs/ltsx/const-lang.wxs" module="langs" /> | ||
<view> | ||
<!-- Get pre-defined localized text --> | ||
<label>{{ ltsx.get(langs.English, 'index.js', 'button_ok_label') }}</label> | ||
<label>{{ ltsx.get(langs.English, 'index.js', 'button_ok_label_example') }}</label> | ||
</view> | ||
@@ -69,3 +74,3 @@ | ||
```html | ||
<wxs src="./src/wsx/ltsx.wxs" module="ltsx" /> | ||
<wxs src="./src/wxs/ltsx.wxs" module="ltsx" /> | ||
@@ -72,0 +77,0 @@ <view> |
Sorry, the diff of this file is not supported yet
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
20991
0
83