{"id":24564736,"url":"https://github.com/abzico/lts","last_synced_at":"2025-03-17T01:44:20.280Z","repository":{"id":57158540,"uuid":"113250681","full_name":"abzico/lts","owner":"abzico","description":"Localization module (marked with WeChat's mini-program supported)","archived":false,"fork":false,"pushed_at":"2018-01-24T23:20:07.000Z","size":393,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-12T01:42:55.019Z","etag":null,"topics":["applet","javascript","js","localization","localized","mini-program","wechat","wxs"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/abzico.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-12-06T00:58:28.000Z","updated_at":"2018-01-24T23:20:32.000Z","dependencies_parsed_at":"2022-09-07T06:21:50.201Z","dependency_job_id":null,"html_url":"https://github.com/abzico/lts","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abzico%2Flts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abzico%2Flts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abzico%2Flts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abzico%2Flts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/abzico","download_url":"https://codeload.github.com/abzico/lts/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243960444,"owners_count":20375101,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["applet","javascript","js","localization","localized","mini-program","wechat","wxs"],"created_at":"2025-01-23T11:29:24.350Z","updated_at":"2025-03-17T01:44:20.260Z","avatar_url":"https://github.com/abzico.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ltsx\nLocalization module (marked with WeChat's mini-program supported)\n\n# Note\n\nTested on macOS only. When you execute `npm --prefix ...` command as shown below on other platforms, it **might** has problem, or none at all.\n\n# Install\n\nInstall this NPM module with `npm install --save ltsx`.\n\n\nImport into your source code by\n\n```javascript\nvar { ltsx, langs } = require('ltsx')\n```\n\n`lts` provides main APIs for you to use.  \n`langs` provides language constants for you to use as parameter when calling one of those APIs.\n\n# APIs\n\nSee [docs](https://abzico.github.io/lts) and look on the right sidebar.\n\n# How to Use with WeChat's mini-program?\n\nChange directory to the root of your WeChat's mini-program project.\n\nInstall 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.\n\nExecute `npm --prefix node_modules/ltsx run wechat-mp -- $PWD/src/wxs/` in which path argument **can be** any depends on your need.\n\n\u003e 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`.\n\nThen modify `./src/wxs/ltsx/defs.wxs` for your pre-defined localized text that will be used throughout the application life cycle.  \nExample of its content is as follows.\n\n```javascript\n// pre-defined definition file\n\nmodule.exports = {\n\t\"index.js\": {\n\t\t\"button_ok_label_example\": {\n\t\t\t\"en_US\": \"OK\",\n\t\t\t\"zh_Hans\": \"好\"\n\t\t}\n\t}\n};\n```\n\nThen inside your .wxml file, you would have something like this.\n\n\u003e Path is relative. So it depends on which source file you try to include `ltsx` to work with your code. Modify it accordingly.\n\n```html\n\u003cwxs src=\"./src/wxs/ltsx/ltsx.wxs\" module=\"ltsx\" /\u003e\n\u003cwxs src=\"./src/wxs/ltsx/const-lang.wxs\" module=\"langs\" /\u003e\n\n\u003cview\u003e\n\t\u003c!-- Get pre-defined localized text --\u003e\n\t\u003clabel\u003e{{ ltsx.get(langs.English, 'index.js', 'button_ok_label_example') }}\u003c/label\u003e\n\u003c/view\u003e\n\n...\n```\n\nor define `lang` variable in your .js code and use it dynamically in .wxml file as follows.\n\n```html\n\u003cwxs src=\"./src/wxs/ltsx.wxs\" module=\"ltsx\" /\u003e\n\n\u003cview\u003e\n\t\u003c!-- Get pre-defined localized text --\u003e\n\t\u003clabel\u003e{{ ltsx.get(lang, 'index.js', 'button_ok_label') }}\u003c/label\u003e\n\u003c/view\u003e\n\n...\n```\n\n# License\n\n[Apache 2.0](https://github.com/abzico/lts/blob/master/README.md), Abzi.co","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabzico%2Flts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fabzico%2Flts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabzico%2Flts/lists"}