<p align="center">
<img width="128" src="https://static.thenounproject.com/png/2556730-200.png">
<h1 align="center" style="margin: 0; text-align: center">@Translations Typescript Decorator</h1>
</p>
Typescripts decorator which helps in:
- All translations in one place with its key
- `Go To Definition` support
- Parameterized translations
- Missing translation generation for quick prototyping
<p style="text-align: center; width: 100%" align="center">
<img style="max-width: 256px; border-radius: 8px; box-shadow: 0 10px 10px -5px rgba(128, 128, 128, 0.25);" src="images/goToDefinition.gif">
</p>
### Install
Install dependencies with npm:
```bash
npm i mustafah/translations
```
### Import
```ts
import Translations from 'translations';
```
### Define your languages
```ts
enum Languages {
Arabic,
English,
German,
French
}
import { configTranslations } from 'translations';
configTranslations({ languagesEnum: Languages });
```
### â¤ï¸ Add translations to your class
```ts
@Component({ ... })
export class Component {
@Translations()
t = {
HelloWorld: [
'Ù
رØبا٠باÙعاÙÙ
',
'Hello World',
'Hallo Welt',
'Bonjour le Monde'
]
};
}
```
### ð¬ Set current language
```ts
setTranslationLanguage(Languages.English);
```
<hr/>
### ð Parameterized translations
```ts
@Translations()
t: any = {
WelcomeTo: (country) => [
`Ø£ÙÙا٠ب٠ÙÙ ${country}`,
`Welcome to ${country}`,
`Willkommen in ${country}`,
`Bienvenue en ${country}`
],
// Countries
Egypt: ['Ù
صر', 'Egypt', 'Ãgypten', 'Ãgypte'],
Germany: ['Ø£ÙÙ
اÙÙا', 'Germany', 'Deutschland', 'Allemagne']
};
setTranslationLanguage(Languages.English);
console.log(this.t.WelcomeTo(this.t.Egypt));
// Welcome to Egypt
setTranslationLanguage(Languages.German);
console.log(this.t.WelcomeTo(this.t.Germany));
// Willkommen in Deutschland
```
<hr/>
### ð Missing translations generation
<p align="center" style="text-align: center">
<img style="max-width: 256px; border-radius: 8px; box-shadow: 0 10px 10px -5px rgba(128, 128, 128, 0.25);" src="images/missingTranslations.gif">
</p>
没有合适的资源?快使用搜索试试~ 我知道了~
翻译:Typescript装饰器,可通过其键将所有翻译集中到一个地方,等等。
共45个文件
js:16个
ts:9个
json:7个
需积分: 9 0 下载量 129 浏览量
2021-02-26
01:56:51
上传
评论
收藏 709KB ZIP 举报
温馨提示
@Translations打字稿装饰器 打字稿装饰器,可帮助: 所有翻译都在同一个地方 Go To Definition支持 参数化翻译 缺少翻译生成功能,无法快速制作原型 安装 使用npm安装依赖项: npm i mustafah/translations 进口 import Translations from 'translations' ; 定义您的语言 enum Languages { Arabic , English , German , French } import { configTranslations } from 'translations' ; configTranslations ( { languagesEnum : Languages } ) ; :red_heart: 将翻译添加到您的班级 @ Component ( { ... } ) export c
资源详情
资源评论
资源推荐
收起资源包目录
translations-main.zip (45个子文件)
translations-main
config
tsconfig.types.json 241B
webpack.config.js 594B
tsconfig.esm.json 266B
tsconfig.umd.json 259B
tsconfig.cjs.json 268B
images
goToDefinition.gif 415KB
missingTranslations.gif 151KB
.husky
commit-msg 110B
.gitignore 1B
pre-commit 85B
common.sh 165B
package.json 2KB
tools
cleanup.js 812B
packagejson.js 498B
.github
workflows
test.yml 760B
publish.yml 1KB
test
Num.test.ts 284B
jest.config.js 275B
LICENSE 1KB
package-lock.json 560KB
dist
umd
index.js 4KB
esm
index.js 6KB
strings.js 603B
copy.js 822B
clipboard.js 2KB
cjs
index.js 6KB
strings.js 713B
copy.js 948B
clipboard.js 2KB
types
strings.d.ts 72B
clipboard.d.ts 90B
copy.d.ts 49B
index.d.ts 425B
src
clipboard.ts 2KB
strings.ts 482B
copy.ts 802B
index.ts 5KB
.eslintrc.js 273B
tsconfig.json 6KB
.gitignore 2KB
commitlint.config.js 64B
.prettierrc.js 124B
README.md 2KB
.eslintignore 49B
.editorconfig 451B
共 45 条
- 1
温暖如故
- 粉丝: 22
- 资源: 4642
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 华硕B250 PLUS支持6789代BIOS
- 基于javaScript开发的图书管理系统+数据库+源码+项目展示+开发文档(毕业设计&课程设计&项目开发)
- HTML+CSS制作的个人博客网页 2.zip
- 华硕B250M-PIXIU支持6789代BIOS
- c# winfrom 音量控制 静音
- 【OpenHarmony】 ArkTS 语法基础 ② ( ArkTS 自定义组件 )
- 前言(完整版):.zip
- 基于java开发最受欢迎的电影购票系统+源码+数据库+项目文档+项目展示(毕业设计&课程设计&项目开发)
- 基于STM32输液监测系统-源程序,LABVIEW上位机,HMI串口屏
- ESG评分与企业绩效之间的关系
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0