
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
The internationalization (i18n) compiler for Angular.
Simple example using ng-trans: https://stackblitz.com/github/ngx-translate/example
Get the complete changelog here: https://www.npmjs.com/package/ng-trans
First you need to install the npm module:
npm i ng-trans --save
You should create simple server trans-server.js file in angular project root or any project using the following options
| Option | Usage | Required |
|---|---|---|
| src | the source files path | required |
| dest | if you need translate output in other directory not in same files (not src) | optional |
| prefix | if have multiple projects | optional |
| transPath | trans json files path | required |
| compName | if you need to trans single component | optional |
| ext | file extensions like ['js', 'ts'] | optional |
after using npm i ng-trans --save to install package create the simple file
var trans = require('ng-trans');
trans({
src: 'src/app',
transPath: 'src/assets/trans'
});
Now you should customize your component files like as the following example
<p>{{'%WelcomePage.HelloWorld.{"en":"Hello World","fr":"Bonjour le monde"}%@trans' | translate}}</p>
Notes: 1- the line should start with
%and end with%@trans2- important: the translate line should ended with object with translated types for exampleenandfrorenandarand you make sure add.in between object and last key in translate levels.{"en":""}. 3- you can use multiple levelslevelOne.LevelTwo.LevelThree. ....... 4- you can write object keys camel casewelcomePageor upper letterWELCOME_PAGEorwelcome_pageor any typing ways and output will beWELCOME_PAGE. 5. you can add trans value inenas same as last key in objectWelcomePage.HelloWorld.{"en":"HelloWorld"}and compiler will rewrite it as human writesHello wold.
import {Component} from '@angular/core';
import {TranslateService} from '@ngx-translate/core';
@Component({
selector: 'app',
.....
})
export class AppComponent {
validation = {isRequeried: '%welcomePAge.validation{"en":"%this field is required%@trans","fr":"Ce champ est requis"'};
constructor(translate: TranslateService) {
}
}
When you run node trans-server.js in project root then open project files you will found % %@trans removed and last object also.
import {Component} from '@angular/core';
import {TranslateService} from '@ngx-translate/core';
@Component({
selector: 'app',
.....
})
export class AppComponent {
validation = {isRequeried: 'WELCOME_PAGE.VALIDATION';
constructor(translate: TranslateService) {
}
}
and HTML
<p>{{'WELCOME_PAGE.HELLO_WORLD' | translate}}</p>
and you can find new files in translate files path en.json and fr.json and map
{
WELCOME_PAGE:{
HELLO_WORLD:"Hello World",
VALIDATION:"this field is required"
}
}
If you need add more translate item do it without write old items or if you need update old one you need only set it in trans mode % .... %@trans and it will overwrite in translated files.
Also you can use commend lines to build translate files without install it in project package use the following commend to download project in your workspace:
git clone https://gitlab.com/ahmedharby9/transapp.git
after download project copy your source files in src in project and create trans directory and then run commend line node app.js src 'src' transPath 'trans'
you can also use node app.js -h or node app.js --help to know more about options.
Finally, this package used to reducing translation time during development work and providing you with the ideal solution in creating an integrated translation in many languages in the simplest way.
FAQs
package for build a translate angular project
We found that ng-trans 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
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.