Initial commit
This commit is contained in:
25
projects/ngx-translate-extract-marker/README.md
Normal file
25
projects/ngx-translate-extract-marker/README.md
Normal file
@@ -0,0 +1,25 @@
|
||||
## Mark strings for extraction using a marker function
|
||||
If, for some reason, you want to extract strings not passed directly to `TranslateService`'s `get()` or `instant()` methods, you can wrap them in a custom marker function to let `ngx-translate-extract` know you want to extract them.
|
||||
|
||||
Install marker function:
|
||||
`npm install @biesbjerg/ngx-translate-extract-marker`
|
||||
|
||||
```ts
|
||||
import { extract } from '@biesbjerg/ngx-translate-extract-marker';
|
||||
|
||||
extract('Extract me');
|
||||
```
|
||||
|
||||
Add the `marker` argument when running the extract script:
|
||||
|
||||
`ngx-translate-extract ... -m extract`
|
||||
|
||||
You can alias the marker function if needed:
|
||||
|
||||
```ts
|
||||
import { extract as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
||||
|
||||
_('Extract me');
|
||||
```
|
||||
|
||||
`ngx-translate-extract ... -m _`
|
32
projects/ngx-translate-extract-marker/karma.conf.js
Normal file
32
projects/ngx-translate-extract-marker/karma.conf.js
Normal file
@@ -0,0 +1,32 @@
|
||||
// Karma configuration file, see link for more information
|
||||
// https://karma-runner.github.io/1.0/config/configuration-file.html
|
||||
|
||||
module.exports = function (config) {
|
||||
config.set({
|
||||
basePath: '',
|
||||
frameworks: ['jasmine', '@angular-devkit/build-angular'],
|
||||
plugins: [
|
||||
require('karma-jasmine'),
|
||||
require('karma-chrome-launcher'),
|
||||
require('karma-jasmine-html-reporter'),
|
||||
require('karma-coverage-istanbul-reporter'),
|
||||
require('@angular-devkit/build-angular/plugins/karma')
|
||||
],
|
||||
client: {
|
||||
clearContext: false // leave Jasmine Spec Runner output visible in browser
|
||||
},
|
||||
coverageIstanbulReporter: {
|
||||
dir: require('path').join(__dirname, '../../coverage/ngx-translate-extract-marker'),
|
||||
reports: ['html', 'lcovonly'],
|
||||
fixWebpackSourcePaths: true
|
||||
},
|
||||
reporters: ['progress', 'kjhtml'],
|
||||
port: 9876,
|
||||
colors: true,
|
||||
logLevel: config.LOG_INFO,
|
||||
autoWatch: true,
|
||||
browsers: ['Chrome'],
|
||||
singleRun: false,
|
||||
restartOnFileChange: true
|
||||
});
|
||||
};
|
7
projects/ngx-translate-extract-marker/ng-package.json
Normal file
7
projects/ngx-translate-extract-marker/ng-package.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
|
||||
"dest": "../../dist/ngx-translate-extract-marker",
|
||||
"lib": {
|
||||
"entryFile": "src/public-api.ts"
|
||||
}
|
||||
}
|
20
projects/ngx-translate-extract-marker/package.json
Normal file
20
projects/ngx-translate-extract-marker/package.json
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"name": "@biesbjerg/ngx-translate-extract-marker",
|
||||
"description": "Function to manually mark strings to be extracted using ngx-translate-extract",
|
||||
"version": "0.0.1",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/biesbjerg/ngx-translate-extract-marker.git"
|
||||
},
|
||||
"author": "Kim Biesbjerg <kim@biesbjerg.com>",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/biesbjerg/ngx-translate-extract-marker/issues"
|
||||
},
|
||||
"homepage": "https://github.com/biesbjerg/ngx-translate-extract-marker",
|
||||
"keywords": [
|
||||
"angular",
|
||||
"ngx-translate",
|
||||
"ngx-translate-extract"
|
||||
]
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
export function extract<T extends string | string[]>(key: T): T {
|
||||
return key;
|
||||
}
|
5
projects/ngx-translate-extract-marker/src/public-api.ts
Normal file
5
projects/ngx-translate-extract-marker/src/public-api.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
/*
|
||||
* Public API Surface of ngx-translate-extract-marker
|
||||
*/
|
||||
|
||||
export * from './lib/ngx-translate-extract-marker';
|
21
projects/ngx-translate-extract-marker/src/test.ts
Normal file
21
projects/ngx-translate-extract-marker/src/test.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
// This file is required by karma.conf.js and loads recursively all the .spec and framework files
|
||||
|
||||
import 'zone.js/dist/zone';
|
||||
import 'zone.js/dist/zone-testing';
|
||||
import { getTestBed } from '@angular/core/testing';
|
||||
import {
|
||||
BrowserDynamicTestingModule,
|
||||
platformBrowserDynamicTesting
|
||||
} from '@angular/platform-browser-dynamic/testing';
|
||||
|
||||
declare const require: any;
|
||||
|
||||
// First, initialize the Angular testing environment.
|
||||
getTestBed().initTestEnvironment(
|
||||
BrowserDynamicTestingModule,
|
||||
platformBrowserDynamicTesting()
|
||||
);
|
||||
// Then we find all the tests.
|
||||
const context = require.context('./', true, /\.spec\.ts$/);
|
||||
// And load the modules.
|
||||
context.keys().map(context);
|
26
projects/ngx-translate-extract-marker/tsconfig.lib.json
Normal file
26
projects/ngx-translate-extract-marker/tsconfig.lib.json
Normal file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "../../out-tsc/lib",
|
||||
"target": "es2015",
|
||||
"declaration": true,
|
||||
"inlineSources": true,
|
||||
"types": [],
|
||||
"lib": [
|
||||
"dom",
|
||||
"es2018"
|
||||
]
|
||||
},
|
||||
"angularCompilerOptions": {
|
||||
"annotateForClosureCompiler": true,
|
||||
"skipTemplateCodegen": true,
|
||||
"strictMetadataEmit": true,
|
||||
"fullTemplateTypeCheck": true,
|
||||
"strictInjectionParameters": true,
|
||||
"enableResourceInlining": true
|
||||
},
|
||||
"exclude": [
|
||||
"src/test.ts",
|
||||
"**/*.spec.ts"
|
||||
]
|
||||
}
|
17
projects/ngx-translate-extract-marker/tsconfig.spec.json
Normal file
17
projects/ngx-translate-extract-marker/tsconfig.spec.json
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "../../out-tsc/spec",
|
||||
"types": [
|
||||
"jasmine",
|
||||
"node"
|
||||
]
|
||||
},
|
||||
"files": [
|
||||
"src/test.ts"
|
||||
],
|
||||
"include": [
|
||||
"**/*.spec.ts",
|
||||
"**/*.d.ts"
|
||||
]
|
||||
}
|
17
projects/ngx-translate-extract-marker/tslint.json
Normal file
17
projects/ngx-translate-extract-marker/tslint.json
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"extends": "../../tslint.json",
|
||||
"rules": {
|
||||
"directive-selector": [
|
||||
true,
|
||||
"attribute",
|
||||
"lib",
|
||||
"camelCase"
|
||||
],
|
||||
"component-selector": [
|
||||
true,
|
||||
"element",
|
||||
"lib",
|
||||
"kebab-case"
|
||||
]
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user