ngx-translate-cut 3.1.1
Install from the command line:
Learn more about npm packages
$ npm install @bartholomej/ngx-translate-cut@3.1.1
Install via package.json:
"@bartholomej/ngx-translate-cut": "3.1.1"
About this version
Angular pipe for cutting translations βοΈ π (plugin for @ngx-translate)
β Angular 13, Ivy and Angular Universal (SSR) compatible
Here's the demo or stackblitz live preview
-
Make sure you have @ngx-translate library installed, because this is its plugin
-
Use yarn (or npm) to install the package
npm install ngx-translate-cut # For Angular 13. See compatibility table.
Choose the version corresponding to your Angular version:
Angular | ngx-translate-cut | Install |
---|---|---|
13 (ivy only) | 3.x | npm install ngx-translate-cut |
12 (ivy only) | 2.x | npm install ngx-translate-cut@2 |
>= 5 < 13 | 1.x | npm install ngx-translate-cut@1 |
- Add
NgxTranslateCutModule
into your moduleimports
(usuallyapp.module.ts
file)
import { NgxTranslateCutModule } from 'ngx-translate-cut';
@NgModule({
// ...
imports: [
// ...
NgxTranslateCutModule
]
})
Strings are separated with |
(pipe sign)
...but you can choose your own symbol
File assets/i18n/en.json
{
"demo": "This is only one 'translate string' with | strong text | and | links"
}
In your template use translateCut:<number>
pipe right after translate
pipe from @ngx-translate library.
{{ 'demo' | translate | translateCut:0 }}
<strong> {{ 'demo' | translate | translateCut:1 }} </strong>
{{ 'demo' | translate | translateCut:2 }}
<a href="#"> {{ 'demo' | translate | translateCut:3 }} </a>
This is only one 'translate string' with strong text and links
If you are not satisfied with the basic settings of the separator (which is |
), you can choose your own separator
import { NgxTranslateCutModule } from 'ngx-translate-cut';
@NgModule({
// ...
imports: [
// ...
NgxTranslateCutModule.forRoot({
// Your separator in translation strings will be `*`
separator: '*'
}),
]
})
Failed to compile.
./node_modules/ngx-translate-cut/fesm2015/ngx-translate-cut.mjs 17:18-28 Can't import the named export 'Injectable' from non EcmaScript module (only default export is available)
You are probably trying to use this library with an older version of Angular version (Angular 5 β 11).
Install copmatibility version instead:
yarn add ngx-translate-cut@1 # for angular 5 β 11
yarn release:patch
# yarn release:minor
# yarn release:major
- Bump version
-next.0
inpackage.json
yarn publish:next
Copyright Β© 2021 Lukas Bartak
Proudly powered by nature π», wind π¨, tea π΅ and beer πΊ ;)
All contents are licensed under the MIT license.
If this project have helped you save time please consider making a donation for some πΊ or π΅ ;)
Original idea comes from: @yuristsepaniuk in this thread.