@colsen1991/ngx-translate-extract-marker
TypeScript icon, indicating that this package has built-in type declarations

3.0.1 • Public • Published

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 ❤️

Package Sidebar

Install

npm i @colsen1991/ngx-translate-extract-marker

Weekly Downloads

6,720

Version

3.0.1

License

MIT

Unpacked Size

37.1 kB

Total Files

27

Last publish

Collaborators

  • colsen91