@colsen1991/ngx-translate-extract-marker
v3.0.1
Published
Function, pipe and directive to manually mark strings to be extracted using ngx-translate-extract
Downloads
27,863
Maintainers
Readme
ngx-translate-extract-marker
This is a fork of a great library by Kim Biesbjerg, but as far as I can tell the original library is unfortunately no longer being developed
Installation
$ npm install @colsen1991/ngx-translate-extract-marker
Important notice
The marker pipe and directive is not supported in Kim's ngx-translate-extract package.
Please use Vendure's instead: $ npm install @colsen1991/ngx-translate-extract
.
Mark strings for extraction using the marker function
If, for some reason, you want to extract strings not passed directly to ngx-translate/TranslateService
's get()
, instant()
or stream()
methods, you can wrap them in a custom marker function to let ngx-translate-extract
know you want to extract them.
Import and use the marker function:
import { marker } from '@colsen1991/ngx-translate-extract-marker';
marker('Extract me');
Or you can alias the marker()
method:
import { marker as _ } from '@colsen1991/ngx-translate-extract-marker';
_('Extract me');
Then run the extract script: $ ngx-translate-extract
Mark strings for extraction using the marker pipe
If, for some reason, you want to extract strings not passed directly to ngx-translate/TranslatePipe
, you can pass them into a custom marker pipe to let ngx-translate-extract
know you want to extract them.
Import and use the marker pipe in your @NgModule
:
import { MarkerPipe } from '@colsen1991/ngx-translate-extract-marker/extras';
@NgModule({ declarations: [MarkerPipe] })
export class YourModule {}
Or use the standalone pipe in your standalone component (careful not to use both methods):
import { MarkerPipeStandalone } from '@colsen1991/ngx-translate-extract-marker/extras';
@Component({ imports: [MarkerPipeStandalone], standalone: true })
export class StandaloneComponent {}
Then mark strings in your templates:
<your-component [yourInput]="'Hello world' | marker"></your-component>
Mark strings for extraction using the marker directive
If, for some reason, you want to extract strings not passed directly to ngx-translate/TranslateDirective
, you can wrap them in a custom marker directive to let ngx-translate-extract
know you want to extract them.
Import and use the marker directive in your @NgModule
:
import { MarkerDirective } from '@colsen1991/ngx-translate-extract-marker/extras';
@NgModule({ declarations: [MarkerDirective] })
export class YourModule {}
Or use the standalone directive in your standalone component (careful not to use both methods):
import { MarkerDirectiveStandalone } from '@colsen1991/ngx-translate-extract-marker/extras';
@NgModule({ imports: [MarkerDirectiveStandalone], standalone: true })
export class StandaloneComponent {}
Then mark strings in your templates:
<p marker>Hello World</p>
Then run the extract script: $ ngx-translate-extract
ngx-translate-extract-marker module
You may also import the marker pipe and directive as a module:
import { MarkerModule } from '@colsen1991/ngx-translate-extract-marker/extras';
@NgModule({ imports: [MarkerModule] })
export class YourModule {}
ngx-translate-extract
See ngx-translate-extract and ngx-translate for more details.
Credits
Original library, idea and code: @biesbjerg/ngx-translate-extract-marker ❤️