Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
An Angular 4 i18n
基于Angular4的国际化方案
imports: [
I18nModule
// or
// I18nModule.forRoot()
]
constructor(private $$I18nServices: $$I18nServices) {
$$I18nServices.setConfig({
prefix: '/demo/i18n',
lang: 'en'
});
}
// I18nConfig
export interface I18nConfig {
prefix: string;
lang?: string;
suffix?: string;
storageKey?: string;
}
lang default 'en';
###i18n resource
// en.json
// {0}, {1}, {name}
// 参数替换支持数组和对象
{
"HELLO_WORLD": "Hello, World!!!",
"HELLO_USER": "Hello, {0}!!!",
"WELCOME_1": "Welcome {0} back to {1}, {0} last login in {2}",
"WELCOME_2": "Welcome {name} back to {site}, {name} last login in {address.province}!!!",
"WELCOME_3": "Welcome {name} back to {site}, {name} last login in {address.province} {0}!!!",
"WELCOME": {
"_3": "Welcome {name} back to {site}, {name} last login in {address.province} {0}!!!"
}
}
// 对象参数注意必须放在最后一个
this.$$I18nServices.getText((text) => {
console.debug(text);
}, 'WELCOME._3', '2017-05-05', {
name: 'mizi',
address: {
province: 'Shanghai'
}
});
<div>{{ 'HELLO_WORLD' | i18n }}</div>
<div>{{ 'HELLO_USER' | i18n: 'Mizi' }}</div>
<div>{{ 'WELCOME_1' | i18n:'Mizi':'i18n' }}</div>
<div>{{ 'WELCOME_1' | i18n:['Mizi','i18n'] : 'Shanghai' }}</div>
<div>{{ 'WELCOME_2' | i18n: userInfo }}</div>
<div>{{ 'WELCOME_3' | i18n: '2017-05-05' : userInfo }}</div>
<div>{{ 'WELCOME._3' | i18n: '2017-05-05' : userInfo }}</div>
<div [i18n]>HELLO_WORLD</div>
<div [i18n]="'Mizi'">HELLO_USER</div>
<div [i18n]="['Mizi', 'i18n']">WELCOME_1</div>
<div [i18n]="[['Mizi', 'i18n'], 'Shanghai']">WELCOME_1</div>
<div [i18n]="['2017-05-05', this.userInfo]">WELCOME._3</div>
FAQs
Angular4.x i18n
The npm package ngx-i18n receives a total of 1 weekly downloads. As such, ngx-i18n popularity was classified as not popular.
We found that ngx-i18n demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.