Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jaywcjlove/translater.js
♣︎ This is a use of HTML comments page translation solution. For a small amount of static pages, this solution is more simple. it has no dependents, Compression only (4KB)
https://github.com/jaywcjlove/translater.js
javascript translates
Last synced: 5 days ago
JSON representation
♣︎ This is a use of HTML comments page translation solution. For a small amount of static pages, this solution is more simple. it has no dependents, Compression only (4KB)
- Host: GitHub
- URL: https://github.com/jaywcjlove/translater.js
- Owner: jaywcjlove
- License: mit
- Created: 2016-03-24T07:27:57.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2024-06-29T14:26:29.000Z (4 months ago)
- Last Synced: 2024-10-29T11:12:06.713Z (5 days ago)
- Topics: javascript, translates
- Language: JavaScript
- Homepage: https://git.io/translater.js
- Size: 293 KB
- Stars: 326
- Watchers: 14
- Forks: 54
- Open Issues: 2
-
Metadata Files:
- Readme: README-zh.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# translater.js
[![](https://jaywcjlove.github.io/sb/ico/npm.svg)](https://www.npmjs.com/package/translater.js) [![](http://jaywcjlove.github.io/sb/status/no-dependencies.svg)](#) [![](http://jaywcjlove.github.io/sb/status/stable.svg)](#) [![](https://jaywcjlove.github.io/sb/license/mit.svg)](#) [![jaywcjlove/sb](https://jaywcjlove.github.io/sb/lang/chinese.svg)](https://jaywcjlove.github.io/translater.js/?lang=cn) [![jaywcjlove/sb](https://jaywcjlove.github.io/sb/lang/english.svg)](https://jaywcjlove.github.io/translater.js/?lang=en) [![CDNJS version](https://img.shields.io/cdnjs/v/translater.js.svg)](https://cdnjs.com/libraries/translater.js)
这是一个利用HTML注释的页面翻译解决方案。对于少量的静态页面,这种解决方案显得更简单。它没有依赖,压缩只有只有(~2kb)。官方文档 [实例预览](http://jaywcjlove.github.io/translater.js/).
- 支持 `IMG` `文本` 切换
- 支持 URL 加载语言
- 支持本地缓存选择![translater.js 动画效果](translater.js.gif)
## 安装
```bash
$ npm install translater.js
``````
import 'translater.js';
```或者手动下载并在HTML中链接 **[translater.js](https://unpkg.com/translater.js/dist/)**,也可以通过 [UNPKG](https://unpkg.com/translater.js/dist/) 下载:
```html
这里是中文
var tran = new Translater({
lang:"jp"
});```
切换语言方法通过超链接
可以通过URL穿参数设置语言
```url
http://127.0.0.1:9005/test/test.html?lang=jp
```## Text
```html
这里是中文
```## Image
```html
```## Input
```html
```
## getLang/setLang
获取或设置当前语言。
```html
var tran = new Translater();
if (tran.getLang() === "default") tran.setLang('en');```