Initial commit

This commit is contained in:
Kim Biesbjerg
2019-06-24 12:39:17 +02:00
parent f51bd22dec
commit 57524a627f
41 changed files with 11696 additions and 2 deletions

View 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 _`

View 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
});
};

View 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"
}
}

View 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"
]
}

View File

@@ -0,0 +1,3 @@
export function extract<T extends string | string[]>(key: T): T {
return key;
}

View File

@@ -0,0 +1,5 @@
/*
* Public API Surface of ngx-translate-extract-marker
*/
export * from './lib/ngx-translate-extract-marker';

View 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);

View 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"
]
}

View 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"
]
}

View File

@@ -0,0 +1,17 @@
{
"extends": "../../tslint.json",
"rules": {
"directive-selector": [
true,
"attribute",
"lib",
"camelCase"
],
"component-selector": [
true,
"element",
"lib",
"kebab-case"
]
}
}