@jsverse/transloco 7.6.1 → 8.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +48 -3
- package/README.md +2 -0
- package/esm2022/index.mjs +4 -5
- package/esm2022/lib/get-fallbacks-loaders.mjs +1 -1
- package/esm2022/lib/lang-resolver.mjs +3 -2
- package/esm2022/lib/resolve-loader.mjs +2 -2
- package/esm2022/lib/scope-resolver.mjs +3 -2
- package/esm2022/lib/template-handler.mjs +2 -2
- package/esm2022/lib/transloco-missing-handler.mjs +1 -1
- package/esm2022/lib/transloco-scope.mjs +1 -1
- package/esm2022/lib/transloco-testing.module.mjs +1 -1
- package/esm2022/lib/transloco.config.mjs +1 -1
- package/esm2022/lib/transloco.directive.mjs +4 -3
- package/esm2022/lib/transloco.interceptor.mjs +1 -1
- package/esm2022/lib/transloco.loader.mjs +1 -1
- package/esm2022/lib/transloco.pipe.mjs +4 -3
- package/esm2022/lib/transloco.providers.mjs +1 -1
- package/esm2022/lib/transloco.service.mjs +4 -3
- package/esm2022/lib/transloco.signal.mjs +1 -1
- package/esm2022/lib/transloco.transpiler.mjs +3 -2
- package/esm2022/lib/transloco.types.mjs +2 -0
- package/esm2022/lib/utils/browser.utils.mjs +30 -0
- package/esm2022/lib/utils/flat.utils.mjs +37 -0
- package/esm2022/lib/utils/lang.utils.mjs +15 -0
- package/esm2022/lib/utils/object.utils.mjs +28 -0
- package/esm2022/lib/utils/pipe.utils.mjs +17 -0
- package/esm2022/lib/utils/scope.utils.mjs +51 -0
- package/esm2022/lib/utils/type.utils.mjs +2 -0
- package/fesm2022/jsverse-transloco.mjs +156 -209
- package/fesm2022/jsverse-transloco.mjs.map +1 -1
- package/index.d.ts +3 -4
- package/lib/get-fallbacks-loaders.d.ts +1 -1
- package/lib/resolve-loader.d.ts +2 -2
- package/lib/scope-resolver.d.ts +2 -1
- package/lib/transloco-missing-handler.d.ts +1 -1
- package/lib/transloco-scope.d.ts +1 -1
- package/lib/transloco-testing.module.d.ts +2 -1
- package/lib/transloco.config.d.ts +1 -1
- package/lib/transloco.directive.d.ts +2 -2
- package/lib/transloco.interceptor.d.ts +1 -1
- package/lib/transloco.loader.d.ts +1 -1
- package/lib/transloco.pipe.d.ts +3 -1
- package/lib/transloco.providers.d.ts +1 -1
- package/lib/transloco.service.d.ts +2 -1
- package/lib/transloco.signal.d.ts +2 -1
- package/lib/transloco.transpiler.d.ts +2 -1
- package/lib/{types.d.ts → transloco.types.d.ts} +1 -2
- package/lib/{browser-lang.d.ts → utils/browser.utils.d.ts} +1 -0
- package/lib/utils/flat.utils.d.ts +3 -0
- package/lib/utils/lang.utils.d.ts +4 -0
- package/lib/utils/object.utils.d.ts +2 -0
- package/lib/utils/pipe.utils.d.ts +8 -0
- package/lib/utils/scope.utils.d.ts +7 -0
- package/lib/utils/type.utils.d.ts +1 -0
- package/package.json +14 -17
- package/schematics/collection.json +12 -0
- package/schematics/ng-add/generators/http-loader.gen.d.ts +5 -0
- package/schematics/{src/ng-add → ng-add}/generators/http-loader.gen.js +1 -0
- package/schematics/ng-add/generators/http-loader.gen.js.map +1 -0
- package/schematics/{src/ng-add → ng-add}/generators/root-module.gen.js +3 -3
- package/schematics/ng-add/generators/root-module.gen.js.map +1 -0
- package/schematics/{src/ng-migrate → ng-add}/index.d.ts +1 -1
- package/schematics/{src/ng-add → ng-add}/index.js +29 -19
- package/schematics/ng-add/index.js.map +1 -0
- package/schematics/ng-add/ng-add.spec.d.ts +1 -0
- package/schematics/ng-add/ng-add.spec.js +45 -0
- package/schematics/ng-add/ng-add.spec.js.map +1 -0
- package/schematics/{src/ng-add → ng-add}/schema.d.ts +0 -8
- package/schematics/ng-add/schema.js +9 -0
- package/schematics/ng-add/schema.js.map +1 -0
- package/schematics/{src/ng-add → ng-add}/schema.json +1 -1
- package/schematics-core/index.d.ts +9 -0
- package/schematics-core/index.js +36 -0
- package/schematics-core/index.js.map +1 -0
- package/schematics-core/testing/create-workspace.d.ts +11 -0
- package/schematics-core/testing/create-workspace.js +34 -0
- package/schematics-core/testing/create-workspace.js.map +1 -0
- package/schematics-core/testing/index.d.ts +2 -0
- package/schematics-core/testing/index.js +19 -0
- package/schematics-core/testing/index.js.map +1 -0
- package/schematics-core/testing/mocks.d.ts +14 -0
- package/schematics-core/testing/mocks.js +10 -0
- package/schematics-core/testing/mocks.js.map +1 -0
- package/{schematics/src/utils/array.js → schematics-core/utils/collections.js} +1 -1
- package/schematics-core/utils/collections.js.map +1 -0
- package/schematics-core/utils/file.d.ts +6 -0
- package/schematics-core/utils/file.js +21 -0
- package/schematics-core/utils/file.js.map +1 -0
- package/{schematics/src → schematics-core}/utils/find-module.js +2 -0
- package/schematics-core/utils/find-module.js.map +1 -0
- package/{schematics/src → schematics-core}/utils/package.d.ts +0 -3
- package/{schematics/src → schematics-core}/utils/package.js +2 -4
- package/schematics-core/utils/package.js.map +1 -0
- package/schematics-core/utils/schematic.d.ts +6 -0
- package/{schematics/src/schematics.utils.js → schematics-core/utils/schematic.js} +6 -6
- package/schematics-core/utils/schematic.js.map +1 -0
- package/schematics-core/utils/translation.d.ts +20 -0
- package/schematics-core/utils/translation.js +83 -0
- package/schematics-core/utils/translation.js.map +1 -0
- package/schematics-core/utils/transloco.d.ts +5 -0
- package/schematics-core/utils/transloco.js +31 -0
- package/schematics-core/utils/transloco.js.map +1 -0
- package/schematics-core/utils/workspace.d.ts +6 -0
- package/{schematics/src/utils/projects.js → schematics-core/utils/workspace.js} +1 -13
- package/schematics-core/utils/workspace.js.map +1 -0
- package/esm2022/lib/browser-lang.mjs +0 -28
- package/esm2022/lib/helpers.mjs +0 -129
- package/esm2022/lib/shared.mjs +0 -73
- package/esm2022/lib/types.mjs +0 -2
- package/lib/helpers.d.ts +0 -20
- package/lib/shared.d.ts +0 -17
- package/schematics/src/assets/i18n/en.json +0 -1
- package/schematics/src/collection.json +0 -59
- package/schematics/src/component/index.d.ts +0 -2
- package/schematics/src/component/index.js +0 -21
- package/schematics/src/component/index.js.map +0 -1
- package/schematics/src/join/index.d.ts +0 -3
- package/schematics/src/join/index.js +0 -79
- package/schematics/src/join/index.js.map +0 -1
- package/schematics/src/join/schema.d.ts +0 -28
- package/schematics/src/join/schema.js +0 -3
- package/schematics/src/join/schema.js.map +0 -1
- package/schematics/src/join/schema.json +0 -43
- package/schematics/src/keys-manager/index.d.ts +0 -5
- package/schematics/src/keys-manager/index.js +0 -96
- package/schematics/src/keys-manager/index.js.map +0 -1
- package/schematics/src/keys-manager/schema.d.ts +0 -19
- package/schematics/src/keys-manager/schema.js +0 -3
- package/schematics/src/keys-manager/schema.js.map +0 -1
- package/schematics/src/keys-manager/schema.json +0 -33
- package/schematics/src/migrate/index.d.ts +0 -3
- package/schematics/src/migrate/index.js +0 -21
- package/schematics/src/migrate/index.js.map +0 -1
- package/schematics/src/migrate/ngx-translate-migration.d.ts +0 -3
- package/schematics/src/migrate/ngx-translate-migration.js +0 -175
- package/schematics/src/migrate/ngx-translate-migration.js.map +0 -1
- package/schematics/src/migrate/schema.d.ts +0 -10
- package/schematics/src/migrate/schema.js +0 -3
- package/schematics/src/migrate/schema.js.map +0 -1
- package/schematics/src/migrate/schema.json +0 -23
- package/schematics/src/ng-add/generators/http-loader.gen.d.ts +0 -4
- package/schematics/src/ng-add/generators/http-loader.gen.js.map +0 -1
- package/schematics/src/ng-add/generators/root-module.gen.js.map +0 -1
- package/schematics/src/ng-add/generators/translation-files.gen.d.ts +0 -4
- package/schematics/src/ng-add/generators/translation-files.gen.js +0 -22
- package/schematics/src/ng-add/generators/translation-files.gen.js.map +0 -1
- package/schematics/src/ng-add/index.d.ts +0 -3
- package/schematics/src/ng-add/index.js.map +0 -1
- package/schematics/src/ng-add/schema.js +0 -14
- package/schematics/src/ng-add/schema.js.map +0 -1
- package/schematics/src/ng-migrate/index.js +0 -14
- package/schematics/src/ng-migrate/index.js.map +0 -1
- package/schematics/src/ng-migrate/ng-migrate.d.ts +0 -5
- package/schematics/src/ng-migrate/ng-migrate.js +0 -105
- package/schematics/src/ng-migrate/ng-migrate.js.map +0 -1
- package/schematics/src/ng-migrate/schema.d.ts +0 -14
- package/schematics/src/ng-migrate/schema.js +0 -3
- package/schematics/src/ng-migrate/schema.js.map +0 -1
- package/schematics/src/ng-migrate/schema.json +0 -27
- package/schematics/src/schematics.utils.d.ts +0 -6
- package/schematics/src/schematics.utils.js.map +0 -1
- package/schematics/src/scope/index.d.ts +0 -3
- package/schematics/src/scope/index.js +0 -101
- package/schematics/src/scope/index.js.map +0 -1
- package/schematics/src/scope/schema.d.ts +0 -28
- package/schematics/src/scope/schema.js +0 -3
- package/schematics/src/scope/schema.js.map +0 -1
- package/schematics/src/scope/schema.json +0 -84
- package/schematics/src/split/index.d.ts +0 -3
- package/schematics/src/split/index.js +0 -66
- package/schematics/src/split/index.js.map +0 -1
- package/schematics/src/split/schema.d.ts +0 -20
- package/schematics/src/split/schema.js +0 -3
- package/schematics/src/split/schema.js.map +0 -1
- package/schematics/src/split/schema.json +0 -35
- package/schematics/src/types.d.ts +0 -5
- package/schematics/src/types.js +0 -10
- package/schematics/src/types.js.map +0 -1
- package/schematics/src/upgrade/index.d.ts +0 -3
- package/schematics/src/upgrade/index.js +0 -19
- package/schematics/src/upgrade/index.js.map +0 -1
- package/schematics/src/upgrade/schema.d.ts +0 -6
- package/schematics/src/upgrade/schema.js +0 -3
- package/schematics/src/upgrade/schema.js.map +0 -1
- package/schematics/src/upgrade/schema.json +0 -16
- package/schematics/src/upgrade/v2.d.ts +0 -1
- package/schematics/src/upgrade/v2.js +0 -88
- package/schematics/src/upgrade/v2.js.map +0 -1
- package/schematics/src/utils/array.js.map +0 -1
- package/schematics/src/utils/config.d.ts +0 -2
- package/schematics/src/utils/config.js +0 -12
- package/schematics/src/utils/config.js.map +0 -1
- package/schematics/src/utils/find-module.js.map +0 -1
- package/schematics/src/utils/package.js.map +0 -1
- package/schematics/src/utils/projects.d.ts +0 -8
- package/schematics/src/utils/projects.js.map +0 -1
- package/schematics/src/utils/translations.d.ts +0 -7
- package/schematics/src/utils/translations.js +0 -30
- package/schematics/src/utils/translations.js.map +0 -1
- package/schematics/src/utils/transloco.d.ts +0 -24
- package/schematics/src/utils/transloco.js +0 -88
- package/schematics/src/utils/transloco.js.map +0 -1
- /package/schematics/{src/ng-add → ng-add}/files/transloco-loader/transloco-loader.__ts__ +0 -0
- /package/schematics/{src/ng-add → ng-add}/files/transloco-module/transloco-root.module.__ts__ +0 -0
- /package/schematics/{src/ng-add → ng-add}/generators/root-module.gen.d.ts +0 -0
- /package/{schematics/src/utils/array.d.ts → schematics-core/utils/collections.d.ts} +0 -0
- /package/{schematics/src → schematics-core}/utils/find-module.d.ts +0 -0
package/lib/resolve-loader.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { TranslocoLoader, TranslocoLoaderData } from './transloco.loader';
|
|
2
|
-
import { InlineLoader } from './types';
|
|
2
|
+
import { InlineLoader } from './transloco.types';
|
|
3
3
|
interface Options {
|
|
4
4
|
inlineLoader?: InlineLoader;
|
|
5
5
|
path: string;
|
|
6
6
|
mainLoader: TranslocoLoader;
|
|
7
7
|
data?: TranslocoLoaderData;
|
|
8
8
|
}
|
|
9
|
-
export declare function resolveLoader(options: Options): import("rxjs").Observable<import("./types").Translation
|
|
9
|
+
export declare function resolveLoader(options: Options): Promise<any> | import("rxjs").Observable<import("./transloco.types").Translation>;
|
|
10
10
|
export {};
|
package/lib/scope-resolver.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { InjectionToken } from '@angular/core';
|
|
2
2
|
import { TranslocoConfig } from './transloco.config';
|
|
3
|
-
import { HashMap } from './
|
|
3
|
+
import { HashMap } from './utils/type.utils';
|
|
4
4
|
import * as i0 from "@angular/core";
|
|
5
5
|
export declare const TRANSLOCO_MISSING_HANDLER: InjectionToken<TranslocoMissingHandlerData>;
|
|
6
6
|
export interface TranslocoMissingHandlerData extends TranslocoConfig {
|
package/lib/transloco-scope.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { ModuleWithProviders } from '@angular/core';
|
|
2
2
|
import { Observable } from 'rxjs';
|
|
3
3
|
import { TranslocoLoader } from './transloco.loader';
|
|
4
|
-
import {
|
|
4
|
+
import { Translation } from './transloco.types';
|
|
5
5
|
import { TranslocoConfig } from './transloco.config';
|
|
6
6
|
import { TranslocoService } from './transloco.service';
|
|
7
|
+
import { HashMap } from './utils/type.utils';
|
|
7
8
|
import * as i0 from "@angular/core";
|
|
8
9
|
import * as i1 from "./transloco.module";
|
|
9
10
|
export interface TranslocoTestingOptions {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EmbeddedViewRef, OnChanges, OnDestroy, OnInit, SimpleChanges } from '@angular/core';
|
|
2
2
|
import { Content } from './template-handler';
|
|
3
|
-
import { HashMap } from './
|
|
3
|
+
import { HashMap } from './utils/type.utils';
|
|
4
4
|
import * as i0 from "@angular/core";
|
|
5
5
|
type TranslateFn = (key: string, params?: HashMap) => any;
|
|
6
6
|
interface ViewContext {
|
|
@@ -23,7 +23,7 @@ export declare class TranslocoDirective implements OnInit, OnDestroy, OnChanges
|
|
|
23
23
|
key: string | undefined;
|
|
24
24
|
params: HashMap;
|
|
25
25
|
inlineScope: string | undefined;
|
|
26
|
-
/** @deprecated use prefix instead, will be removed in Transloco
|
|
26
|
+
/** @deprecated use prefix instead, will be removed in Transloco v9 */
|
|
27
27
|
inlineRead: string | undefined;
|
|
28
28
|
prefix: string | undefined;
|
|
29
29
|
inlineLang: string | undefined;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { InjectionToken } from '@angular/core';
|
|
2
|
-
import { Translation } from './types';
|
|
2
|
+
import { Translation } from './transloco.types';
|
|
3
3
|
import * as i0 from "@angular/core";
|
|
4
4
|
export declare const TRANSLOCO_INTERCEPTOR: InjectionToken<TranslocoInterceptor>;
|
|
5
5
|
export interface TranslocoInterceptor {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { InjectionToken } from '@angular/core';
|
|
2
2
|
import { Observable } from 'rxjs';
|
|
3
|
-
import { Translation } from './types';
|
|
3
|
+
import { Translation } from './transloco.types';
|
|
4
4
|
export interface TranslocoLoader {
|
|
5
5
|
getTranslation(lang: string, data?: TranslocoLoaderData): Observable<Translation> | Promise<Translation>;
|
|
6
6
|
}
|
package/lib/transloco.pipe.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { ChangeDetectorRef, OnDestroy, PipeTransform } from '@angular/core';
|
|
2
|
+
import { OrArray } from '@jsverse/utils';
|
|
2
3
|
import { TranslocoService } from './transloco.service';
|
|
3
|
-
import {
|
|
4
|
+
import { TranslocoScope } from './transloco.types';
|
|
5
|
+
import { HashMap } from './utils/type.utils';
|
|
4
6
|
import * as i0 from "@angular/core";
|
|
5
7
|
export declare class TranslocoPipe implements PipeTransform, OnDestroy {
|
|
6
8
|
private service;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { EnvironmentProviders, Provider, Type } from '@angular/core';
|
|
2
2
|
import { TranslocoLoader } from './transloco.loader';
|
|
3
3
|
import { PartialTranslocoConfig } from './transloco.config';
|
|
4
|
-
import { TranslocoScope } from './types';
|
|
4
|
+
import { TranslocoScope } from './transloco.types';
|
|
5
5
|
import { TranslocoTranspiler } from './transloco.transpiler';
|
|
6
6
|
import { TranslocoMissingHandler } from './transloco-missing-handler';
|
|
7
7
|
import { TranslocoInterceptor } from './transloco.interceptor';
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { Observable } from 'rxjs';
|
|
2
2
|
import { TranslocoLoader } from './transloco.loader';
|
|
3
3
|
import { TranslocoTranspiler } from './transloco.transpiler';
|
|
4
|
-
import { AvailableLangs,
|
|
4
|
+
import { AvailableLangs, InlineLoader, LoadOptions, SetTranslationOptions, TranslateParams, Translation, TranslocoEvents, TranslocoScope } from './transloco.types';
|
|
5
5
|
import { TranslocoConfig } from './transloco.config';
|
|
6
6
|
import { TranslocoMissingHandler } from './transloco-missing-handler';
|
|
7
7
|
import { TranslocoInterceptor } from './transloco.interceptor';
|
|
8
8
|
import { TranslocoFallbackStrategy } from './transloco-fallback-strategy';
|
|
9
|
+
import { HashMap } from './utils/type.utils';
|
|
9
10
|
import * as i0 from "@angular/core";
|
|
10
11
|
export declare function translate<T = string>(key: TranslateParams, params?: HashMap, lang?: string): T;
|
|
11
12
|
export declare function translateObject<T>(key: TranslateParams, params?: HashMap, lang?: string): T | T[];
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Injector, Signal } from '@angular/core';
|
|
2
|
-
import {
|
|
2
|
+
import { Translation, TranslocoScope } from './transloco.types';
|
|
3
|
+
import { HashMap } from './utils/type.utils';
|
|
3
4
|
type ScopeType = string | TranslocoScope | TranslocoScope[];
|
|
4
5
|
type SignalKey = Signal<string> | Signal<string[]> | Signal<string>[];
|
|
5
6
|
type TranslateSignalKey = string | string[] | SignalKey;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { InjectionToken, Injector } from '@angular/core';
|
|
2
|
-
import {
|
|
2
|
+
import { Translation } from './transloco.types';
|
|
3
3
|
import { TranslocoConfig } from './transloco.config';
|
|
4
|
+
import { HashMap } from './utils/type.utils';
|
|
4
5
|
import * as i0 from "@angular/core";
|
|
5
6
|
export declare const TRANSLOCO_TRANSPILER: InjectionToken<TranslocoTranspiler>;
|
|
6
7
|
export interface TranslocoTranspiler {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { HashMap } from './utils/type.utils';
|
|
2
2
|
export interface LoadedEvent {
|
|
3
3
|
type: 'translationLoadSuccess';
|
|
4
4
|
wasFailure: boolean;
|
|
@@ -34,7 +34,6 @@ export interface ProviderScope {
|
|
|
34
34
|
loader?: InlineLoader;
|
|
35
35
|
alias?: string;
|
|
36
36
|
}
|
|
37
|
-
export type OrArray<T> = T | T[];
|
|
38
37
|
export type TranslocoScope = ProviderScope | string | undefined;
|
|
39
38
|
export type InlineLoader = HashMap<() => Promise<Translation>>;
|
|
40
39
|
export interface LoadOptions {
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { OperatorFunction } from 'rxjs';
|
|
2
|
+
import { TranslocoService } from '../transloco.service';
|
|
3
|
+
export declare function shouldListenToLangChanges(service: TranslocoService, lang?: string): boolean;
|
|
4
|
+
export declare function listenOrNotOperator<T>(listenToLangChange?: boolean): OperatorFunction<T, T>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @example
|
|
3
|
+
*
|
|
4
|
+
* getPipeValue('todos|scoped', 'scoped') [true, 'todos']
|
|
5
|
+
* getPipeValue('en|static', 'static') [true, 'en']
|
|
6
|
+
* getPipeValue('en', 'static') [false, 'en']
|
|
7
|
+
*/
|
|
8
|
+
export declare function getPipeValue(str: string | undefined, value: string, char?: string): [boolean, string];
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { InlineLoader, LoadedEvent, ProviderScope, TranslocoScope } from '../transloco.types';
|
|
2
|
+
export declare function getScopeFromLang(lang: string): string;
|
|
3
|
+
export declare function getLangFromScope(lang: string): string;
|
|
4
|
+
export declare function isScopeObject(item: any): item is ProviderScope;
|
|
5
|
+
export declare function hasInlineLoader(item: any): item is ProviderScope;
|
|
6
|
+
export declare function resolveInlineLoader(providerScope: TranslocoScope | null, scope?: string): InlineLoader | undefined;
|
|
7
|
+
export declare function getEventPayload(lang: string): LoadedEvent['payload'];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type HashMap<T = any> = Record<string, T>;
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsverse/transloco",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.0.1",
|
|
4
4
|
"description": "The internationalization (i18n) library for Angular",
|
|
5
|
-
"schematics": "./schematics/
|
|
5
|
+
"schematics": "./schematics/collection.json",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
8
8
|
},
|
|
@@ -15,27 +15,25 @@
|
|
|
15
15
|
"url": "https://github.com/jsverse/transloco"
|
|
16
16
|
},
|
|
17
17
|
"keywords": [
|
|
18
|
-
"
|
|
19
|
-
"angular 2",
|
|
18
|
+
"Angular",
|
|
20
19
|
"i18n",
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
20
|
+
"Translate",
|
|
21
|
+
"Angular Translate",
|
|
22
|
+
"Transloco",
|
|
23
|
+
"Schematics",
|
|
24
|
+
"Angular CLI"
|
|
25
25
|
],
|
|
26
26
|
"license": "MIT",
|
|
27
27
|
"peerDependencies": {
|
|
28
|
-
"@angular/core": ">=16.0.0"
|
|
28
|
+
"@angular/core": ">=16.0.0",
|
|
29
|
+
"rxjs": ">=6.0.0"
|
|
29
30
|
},
|
|
30
31
|
"dependencies": {
|
|
31
|
-
"fs-extra": "^11.0.0",
|
|
32
|
-
"glob": "^10.0.0",
|
|
33
32
|
"tslib": "^2.2.0",
|
|
34
|
-
"@jsverse/
|
|
35
|
-
"
|
|
36
|
-
"ora": "^5.4.1",
|
|
37
|
-
"lodash.kebabcase": "^4.1.1"
|
|
33
|
+
"@jsverse/utils": "1.0.0-beta.5",
|
|
34
|
+
"@jsverse/transloco-utils": "^8.0.1"
|
|
38
35
|
},
|
|
36
|
+
"sideEffects": false,
|
|
39
37
|
"module": "fesm2022/jsverse-transloco.mjs",
|
|
40
38
|
"typings": "index.d.ts",
|
|
41
39
|
"exports": {
|
|
@@ -48,6 +46,5 @@
|
|
|
48
46
|
"esm": "./esm2022/jsverse-transloco.mjs",
|
|
49
47
|
"default": "./fesm2022/jsverse-transloco.mjs"
|
|
50
48
|
}
|
|
51
|
-
}
|
|
52
|
-
"sideEffects": false
|
|
49
|
+
}
|
|
53
50
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": ["@schematics/angular"],
|
|
3
|
+
"$schema": "../../../node_modules/@angular-devkit/schematics/collection-schema.json",
|
|
4
|
+
"schematics": {
|
|
5
|
+
"ng-add": {
|
|
6
|
+
"save": "dependencies",
|
|
7
|
+
"factory": "./ng-add/index#ngAdd",
|
|
8
|
+
"schema": "./ng-add/schema.json",
|
|
9
|
+
"description": "Add Transloco to your project."
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -5,6 +5,7 @@ const schematics_1 = require("@angular-devkit/schematics");
|
|
|
5
5
|
function createLoaderFile({ ssr, loaderPath }) {
|
|
6
6
|
return (0, schematics_1.apply)((0, schematics_1.url)(`./files/transloco-loader`), [
|
|
7
7
|
(0, schematics_1.template)({
|
|
8
|
+
// Replace the __ts__ with ts
|
|
8
9
|
ts: 'ts',
|
|
9
10
|
loaderPrefix: ssr ? '${environment.baseUrl}' : '',
|
|
10
11
|
}),
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-loader.gen.js","sourceRoot":"","sources":["../../../../../../libs/transloco/schematics/ng-add/generators/http-loader.gen.ts"],"names":[],"mappings":";;AAOA,4CASC;AAhBD,2DAAwE;AAOxE,SAAgB,gBAAgB,CAAC,EAAE,GAAG,EAAE,UAAU,EAA0B;IAC1E,OAAO,IAAA,kBAAK,EAAC,IAAA,gBAAG,EAAC,0BAA0B,CAAC,EAAE;QAC5C,IAAA,qBAAQ,EAAC;YACP,6BAA6B;YAC7B,EAAE,EAAE,IAAI;YACR,YAAY,EAAE,GAAG,CAAC,CAAC,CAAC,wBAAwB,CAAC,CAAC,CAAC,EAAE;SAClD,CAAC;QACF,IAAA,iBAAI,EAAC,GAAG,EAAE,UAAU,CAAC;KACtB,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.createTranslocoModule = createTranslocoModule;
|
|
4
4
|
const path = require("node:path");
|
|
5
5
|
const schematics_1 = require("@angular-devkit/schematics");
|
|
6
|
-
const
|
|
6
|
+
const schematics_core_1 = require("../../../schematics-core");
|
|
7
7
|
function createTranslocoModule({ isLib, ssr, langs, modulePath, sourceRoot, host, }) {
|
|
8
8
|
const envPath = path
|
|
9
9
|
.relative(modulePath, `${sourceRoot}/environments/environment`)
|
|
@@ -16,9 +16,9 @@ function createTranslocoModule({ isLib, ssr, langs, modulePath, sourceRoot, host
|
|
|
16
16
|
}
|
|
17
17
|
return (0, schematics_1.apply)((0, schematics_1.url)(`./files/transloco-module`), [
|
|
18
18
|
(0, schematics_1.template)({
|
|
19
|
+
// Replace the __ts__ with ts
|
|
19
20
|
ts: 'ts',
|
|
20
|
-
stringifyList:
|
|
21
|
-
isLib,
|
|
21
|
+
stringifyList: schematics_core_1.stringifyList,
|
|
22
22
|
langs,
|
|
23
23
|
importEnv: ssr || envFileExists,
|
|
24
24
|
envPath,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"root-module.gen.js","sourceRoot":"","sources":["../../../../../../libs/transloco/schematics/ng-add/generators/root-module.gen.ts"],"names":[],"mappings":";;AAaA,sDAwCC;AArDD,kCAAkC;AAElC,2DAOoC;AAEpC,8DAAyD;AAEzD,SAAgB,qBAAqB,CAAC,EACpC,KAAK,EACL,GAAG,EACH,KAAK,EACL,UAAU,EACV,UAAU,EACV,IAAI,GAQL;IACC,MAAM,OAAO,GAAG,IAAI;SACjB,QAAQ,CAAC,UAAU,EAAE,GAAG,UAAU,2BAA2B,CAAC;SAC9D,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC;SACf,IAAI,CAAC,GAAG,CAAC,CAAC;IACb,MAAM,aAAa,GAAG,IAAI,CAAC,MAAM,CAC/B,GAAG,UAAU,8BAA8B,CAC5C,CAAC;IACF,IAAI,QAAQ,GAAG,aAAa,CAAC,CAAC,CAAC,wBAAwB,CAAC,CAAC,CAAC,cAAc,CAAC;IAEzE,IAAI,KAAK,EAAE,CAAC;QACV,QAAQ,GAAG,OAAO,CAAC;IACrB,CAAC;IAED,OAAO,IAAA,kBAAK,EAAC,IAAA,gBAAG,EAAC,0BAA0B,CAAC,EAAE;QAC5C,IAAA,qBAAQ,EAAC;YACP,6BAA6B;YAC7B,EAAE,EAAE,IAAI;YACR,aAAa,EAAb,+BAAa;YACb,KAAK;YACL,SAAS,EAAE,GAAG,IAAI,aAAa;YAC/B,OAAO;YACP,QAAQ;SACT,CAAC;QACF,IAAA,iBAAI,EAAC,GAAG,EAAE,UAAU,CAAC;KACtB,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,45 +1,55 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
12
|
+
exports.ngAdd = ngAdd;
|
|
4
13
|
const node_path_1 = require("node:path");
|
|
5
14
|
const schematics_1 = require("@angular-devkit/schematics");
|
|
6
15
|
const ng_ast_utils_1 = require("@schematics/angular/utility/ng-ast-utils");
|
|
7
16
|
const util_1 = require("@schematics/angular/utility/standalone/util");
|
|
8
17
|
const rules_1 = require("@schematics/angular/utility/standalone/rules");
|
|
9
18
|
const app_config_1 = require("@schematics/angular/utility/standalone/app_config");
|
|
10
|
-
const
|
|
11
|
-
const projects_1 = require("../utils/projects");
|
|
12
|
-
const translations_1 = require("../utils/translations");
|
|
13
|
-
const transloco_1 = require("../utils/transloco");
|
|
19
|
+
const schematics_core_1 = require("../../schematics-core");
|
|
14
20
|
const schema_1 = require("./schema");
|
|
15
21
|
const http_loader_gen_1 = require("./generators/http-loader.gen");
|
|
16
|
-
const translation_files_gen_1 = require("./generators/translation-files.gen");
|
|
17
22
|
const root_module_gen_1 = require("./generators/root-module.gen");
|
|
18
23
|
function updateEnvironmentBaseUrl(host, sourceRoot, defaultValue) {
|
|
19
24
|
const template = `$1{
|
|
20
25
|
baseUrl: '${defaultValue}',`;
|
|
21
|
-
(0,
|
|
26
|
+
(0, schematics_core_1.setEnvironments)(host, sourceRoot, (env) => env.indexOf('baseUrl') === -1
|
|
22
27
|
? env.replace(/(environment.*=*)\{/, template)
|
|
23
28
|
: env);
|
|
24
29
|
}
|
|
25
|
-
function resolveLoaderPath({ host, mainPath, isStandalone, modulePath }) {
|
|
30
|
+
function resolveLoaderPath({ host, mainPath, isStandalone, modulePath, }) {
|
|
31
|
+
var _a;
|
|
26
32
|
let resolved = modulePath;
|
|
27
33
|
if (isStandalone) {
|
|
28
34
|
const bootstrapCall = (0, util_1.findBootstrapApplicationCall)(host, mainPath);
|
|
29
35
|
resolved =
|
|
30
|
-
(0, app_config_1.findAppConfig)(bootstrapCall, host, mainPath)
|
|
36
|
+
((_a = (0, app_config_1.findAppConfig)(bootstrapCall, host, mainPath)) === null || _a === void 0 ? void 0 : _a.filePath) || mainPath;
|
|
31
37
|
resolved = (0, node_path_1.dirname)(resolved);
|
|
32
38
|
}
|
|
33
39
|
return resolved;
|
|
34
40
|
}
|
|
35
|
-
function
|
|
36
|
-
return
|
|
41
|
+
function ngAdd(options) {
|
|
42
|
+
return (host, context) => __awaiter(this, void 0, void 0, function* () {
|
|
43
|
+
var _a;
|
|
37
44
|
const langs = options.langs.split(',').map((l) => l.trim());
|
|
38
|
-
|
|
39
|
-
|
|
45
|
+
if (!options.project) {
|
|
46
|
+
throw new schematics_1.SchematicsException('Project name is required. Are you using Nx? In Nx you must explicitly provide the project name using --project=<project-name>');
|
|
47
|
+
}
|
|
48
|
+
const project = (0, schematics_core_1.getProject)(host, options.project);
|
|
49
|
+
const sourceRoot = (_a = project.sourceRoot) !== null && _a !== void 0 ? _a : 'src';
|
|
40
50
|
const isLib = project.projectType === 'library';
|
|
41
51
|
const assetsPath = `${sourceRoot}/${options.path}`;
|
|
42
|
-
const mainPath =
|
|
52
|
+
const mainPath = yield (0, util_1.getMainFilePath)(host, options.project);
|
|
43
53
|
const isStandalone = (0, ng_ast_utils_1.isStandaloneApp)(host, mainPath);
|
|
44
54
|
const modulePath = isStandalone
|
|
45
55
|
? ''
|
|
@@ -63,9 +73,9 @@ function default_1(options) {
|
|
|
63
73
|
loaderPath,
|
|
64
74
|
})));
|
|
65
75
|
}
|
|
66
|
-
const hasTranslationFiles = (0,
|
|
76
|
+
const hasTranslationFiles = (0, schematics_core_1.checkIfTranslationFilesExist)(assetsPath, langs, '.json', true);
|
|
67
77
|
if (!hasTranslationFiles) {
|
|
68
|
-
actions.push((0, schematics_1.mergeWith)((0,
|
|
78
|
+
actions.push((0, schematics_1.mergeWith)((0, schematics_core_1.createTranslateFiles)(langs, assetsPath)));
|
|
69
79
|
}
|
|
70
80
|
if (isStandalone) {
|
|
71
81
|
actions.push((0, rules_1.addRootProvider)(options.project, ({ code, external }) => {
|
|
@@ -73,7 +83,7 @@ function default_1(options) {
|
|
|
73
83
|
external('TranslocoHttpLoader', './transloco-loader');
|
|
74
84
|
return code `${external('provideTransloco', '@jsverse/transloco')}({
|
|
75
85
|
config: {
|
|
76
|
-
availableLangs: [${(0,
|
|
86
|
+
availableLangs: [${(0, schematics_core_1.stringifyList)(langs)}],
|
|
77
87
|
defaultLang: '${langs[0]}',
|
|
78
88
|
// Remove this option if your application doesn't support changing language in runtime.
|
|
79
89
|
reRenderOnLangChange: true,
|
|
@@ -96,8 +106,8 @@ function default_1(options) {
|
|
|
96
106
|
if (options.ssr) {
|
|
97
107
|
updateEnvironmentBaseUrl(host, sourceRoot, 'http://localhost:4200');
|
|
98
108
|
}
|
|
99
|
-
(0,
|
|
109
|
+
(0, schematics_core_1.createGlobalConfig)(host, langs, assetsPath);
|
|
100
110
|
return (0, schematics_1.chain)(actions)(host, context);
|
|
101
|
-
};
|
|
111
|
+
});
|
|
102
112
|
}
|
|
103
113
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../libs/transloco/schematics/ng-add/index.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const nodePath = require("node:path");
|
|
13
|
+
const testing_1 = require("@angular-devkit/schematics/testing");
|
|
14
|
+
const testing_2 = require("../../schematics-core/testing");
|
|
15
|
+
const collectionPath = nodePath.join(__dirname, '../collection.json');
|
|
16
|
+
describe('ng add', () => {
|
|
17
|
+
const schematicRunner = new testing_1.SchematicTestRunner('schematics', collectionPath);
|
|
18
|
+
describe('Ng module', () => {
|
|
19
|
+
it('should add transloco to specified project', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
20
|
+
const options = { project: 'bar' };
|
|
21
|
+
const tree = yield schematicRunner.runSchematic('ng-add', options, yield (0, testing_2.createWorkspace)(schematicRunner, {
|
|
22
|
+
appOptions: { standalone: false },
|
|
23
|
+
}));
|
|
24
|
+
expect(tree).toBeDefined();
|
|
25
|
+
expect(tree.files).toContain('/transloco.config.ts');
|
|
26
|
+
expect(tree.files).toContain('/projects/bar/src/app/transloco-loader.ts');
|
|
27
|
+
expect(tree.files).toContain('/projects/bar/src/app/transloco-root.module.ts');
|
|
28
|
+
expect(readFile(tree, 'app/transloco-root.module.ts')).toContain("from './transloco-loader'");
|
|
29
|
+
}));
|
|
30
|
+
});
|
|
31
|
+
describe('Standalone', () => {
|
|
32
|
+
it('should add transloco to specified standalone project', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
33
|
+
const options = { project: 'bar' };
|
|
34
|
+
const tree = yield schematicRunner.runSchematic('ng-add', options, yield (0, testing_2.createWorkspace)(schematicRunner));
|
|
35
|
+
expect(tree).toBeDefined();
|
|
36
|
+
expect(tree.files).toContain('/transloco.config.ts');
|
|
37
|
+
expect(tree.files).toContain('/projects/bar/src/app/transloco-loader.ts');
|
|
38
|
+
expect(readFile(tree, 'app/app.config.ts')).toContain('provideTransloco(');
|
|
39
|
+
}));
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
function readFile(host, path) {
|
|
43
|
+
return host.get(`/projects/bar/src/${path}`).content.toString();
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=ng-add.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ng-add.spec.js","sourceRoot":"","sources":["../../../../../libs/transloco/schematics/ng-add/ng-add.spec.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,sCAAsC;AAEtC,gEAG4C;AAE5C,2DAAgE;AAIhE,MAAM,cAAc,GAAG,QAAQ,CAAC,IAAI,CAAC,SAAS,EAAE,oBAAoB,CAAC,CAAC;AAEtE,QAAQ,CAAC,QAAQ,EAAE,GAAG,EAAE;IACtB,MAAM,eAAe,GAAG,IAAI,6BAAmB,CAAC,YAAY,EAAE,cAAc,CAAC,CAAC;IAE9E,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;QACzB,EAAE,CAAC,2CAA2C,EAAE,GAAS,EAAE;YACzD,MAAM,OAAO,GAAkB,EAAE,OAAO,EAAE,KAAK,EAAmB,CAAC;YACnE,MAAM,IAAI,GAAG,MAAM,eAAe,CAAC,YAAY,CAC7C,QAAQ,EACR,OAAO,EACP,MAAM,IAAA,yBAAe,EAAC,eAAe,EAAE;gBACrC,UAAU,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE;aAClC,CAAC,CACH,CAAC;YACF,MAAM,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC;YAC3B,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,sBAAsB,CAAC,CAAC;YACrD,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,2CAA2C,CAAC,CAAC;YAC1E,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,SAAS,CAC1B,gDAAgD,CACjD,CAAC;YACF,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,8BAA8B,CAAC,CAAC,CAAC,SAAS,CAC9D,2BAA2B,CAC5B,CAAC;QACJ,CAAC,CAAA,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;QAC1B,EAAE,CAAC,sDAAsD,EAAE,GAAS,EAAE;YACpE,MAAM,OAAO,GAAkB,EAAE,OAAO,EAAE,KAAK,EAAmB,CAAC;YACnE,MAAM,IAAI,GAAG,MAAM,eAAe,CAAC,YAAY,CAC7C,QAAQ,EACR,OAAO,EACP,MAAM,IAAA,yBAAe,EAAC,eAAe,CAAC,CACvC,CAAC;YACF,MAAM,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC;YAC3B,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,sBAAsB,CAAC,CAAC;YACrD,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,2CAA2C,CAAC,CAAC;YAC1E,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,mBAAmB,CAAC,CAAC,CAAC,SAAS,CACnD,mBAAmB,CACpB,CAAC;QACJ,CAAC,CAAA,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,SAAS,QAAQ,CAAC,IAAkB,EAAE,IAAY;IAChD,OAAO,IAAI,CAAC,GAAG,CAAC,qBAAqB,IAAI,EAAE,CAAE,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;AACnE,CAAC"}
|
|
@@ -2,10 +2,6 @@ export declare enum Loaders {
|
|
|
2
2
|
Http = "Http",
|
|
3
3
|
Webpack = "Webpack"
|
|
4
4
|
}
|
|
5
|
-
export declare enum TranslationFileTypes {
|
|
6
|
-
Typescript = "Typescript",
|
|
7
|
-
JSON = "JSON"
|
|
8
|
-
}
|
|
9
5
|
export interface SchemaOptions {
|
|
10
6
|
/**
|
|
11
7
|
* The languages of the project.
|
|
@@ -15,10 +11,6 @@ export interface SchemaOptions {
|
|
|
15
11
|
* The translations loader
|
|
16
12
|
*/
|
|
17
13
|
loader: Loaders;
|
|
18
|
-
/**
|
|
19
|
-
* The translation files type.
|
|
20
|
-
*/
|
|
21
|
-
translateType: TranslationFileTypes;
|
|
22
14
|
/**
|
|
23
15
|
* The translation files folder.
|
|
24
16
|
*/
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Loaders = void 0;
|
|
4
|
+
var Loaders;
|
|
5
|
+
(function (Loaders) {
|
|
6
|
+
Loaders["Http"] = "Http";
|
|
7
|
+
Loaders["Webpack"] = "Webpack";
|
|
8
|
+
})(Loaders || (exports.Loaders = Loaders = {}));
|
|
9
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../../../libs/transloco/schematics/ng-add/schema.ts"],"names":[],"mappings":";;;AAAA,IAAY,OAGX;AAHD,WAAY,OAAO;IACjB,wBAAa,CAAA;IACb,8BAAmB,CAAA;AACrB,CAAC,EAHW,OAAO,uBAAP,OAAO,QAGlB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { stringifyList, coerceArray } from './utils/collections';
|
|
2
|
+
export { addScriptToPackageJson } from './utils/package';
|
|
3
|
+
export { getProject, setEnvironments, getWorkspace, setWorkspace, } from './utils/workspace';
|
|
4
|
+
export { createGlobalConfig, getGlobalConfig, updateGlobalConfig, } from './utils/transloco';
|
|
5
|
+
export { createTranslateFiles, checkIfTranslationFilesExist, } from './utils/translation';
|
|
6
|
+
export { getTranslationEntryPaths, getTranslationFiles, getTranslationKey, getTranslationsRoot, createTranslateFilesFromOptions, } from './utils/translation';
|
|
7
|
+
export { hasFiles, hasSubdirs, getJsonFileContent, writeToJson, } from './utils/file';
|
|
8
|
+
export { NAMES } from './utils/schematic';
|
|
9
|
+
export { findModuleFromOptions } from './utils/find-module';
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.findModuleFromOptions = exports.NAMES = exports.writeToJson = exports.getJsonFileContent = exports.hasSubdirs = exports.hasFiles = exports.createTranslateFilesFromOptions = exports.getTranslationsRoot = exports.getTranslationKey = exports.getTranslationFiles = exports.getTranslationEntryPaths = exports.checkIfTranslationFilesExist = exports.createTranslateFiles = exports.updateGlobalConfig = exports.getGlobalConfig = exports.createGlobalConfig = exports.setWorkspace = exports.getWorkspace = exports.setEnvironments = exports.getProject = exports.addScriptToPackageJson = exports.coerceArray = exports.stringifyList = void 0;
|
|
4
|
+
var collections_1 = require("./utils/collections");
|
|
5
|
+
Object.defineProperty(exports, "stringifyList", { enumerable: true, get: function () { return collections_1.stringifyList; } });
|
|
6
|
+
Object.defineProperty(exports, "coerceArray", { enumerable: true, get: function () { return collections_1.coerceArray; } });
|
|
7
|
+
var package_1 = require("./utils/package");
|
|
8
|
+
Object.defineProperty(exports, "addScriptToPackageJson", { enumerable: true, get: function () { return package_1.addScriptToPackageJson; } });
|
|
9
|
+
var workspace_1 = require("./utils/workspace");
|
|
10
|
+
Object.defineProperty(exports, "getProject", { enumerable: true, get: function () { return workspace_1.getProject; } });
|
|
11
|
+
Object.defineProperty(exports, "setEnvironments", { enumerable: true, get: function () { return workspace_1.setEnvironments; } });
|
|
12
|
+
Object.defineProperty(exports, "getWorkspace", { enumerable: true, get: function () { return workspace_1.getWorkspace; } });
|
|
13
|
+
Object.defineProperty(exports, "setWorkspace", { enumerable: true, get: function () { return workspace_1.setWorkspace; } });
|
|
14
|
+
var transloco_1 = require("./utils/transloco");
|
|
15
|
+
Object.defineProperty(exports, "createGlobalConfig", { enumerable: true, get: function () { return transloco_1.createGlobalConfig; } });
|
|
16
|
+
Object.defineProperty(exports, "getGlobalConfig", { enumerable: true, get: function () { return transloco_1.getGlobalConfig; } });
|
|
17
|
+
Object.defineProperty(exports, "updateGlobalConfig", { enumerable: true, get: function () { return transloco_1.updateGlobalConfig; } });
|
|
18
|
+
var translation_1 = require("./utils/translation");
|
|
19
|
+
Object.defineProperty(exports, "createTranslateFiles", { enumerable: true, get: function () { return translation_1.createTranslateFiles; } });
|
|
20
|
+
Object.defineProperty(exports, "checkIfTranslationFilesExist", { enumerable: true, get: function () { return translation_1.checkIfTranslationFilesExist; } });
|
|
21
|
+
var translation_2 = require("./utils/translation");
|
|
22
|
+
Object.defineProperty(exports, "getTranslationEntryPaths", { enumerable: true, get: function () { return translation_2.getTranslationEntryPaths; } });
|
|
23
|
+
Object.defineProperty(exports, "getTranslationFiles", { enumerable: true, get: function () { return translation_2.getTranslationFiles; } });
|
|
24
|
+
Object.defineProperty(exports, "getTranslationKey", { enumerable: true, get: function () { return translation_2.getTranslationKey; } });
|
|
25
|
+
Object.defineProperty(exports, "getTranslationsRoot", { enumerable: true, get: function () { return translation_2.getTranslationsRoot; } });
|
|
26
|
+
Object.defineProperty(exports, "createTranslateFilesFromOptions", { enumerable: true, get: function () { return translation_2.createTranslateFilesFromOptions; } });
|
|
27
|
+
var file_1 = require("./utils/file");
|
|
28
|
+
Object.defineProperty(exports, "hasFiles", { enumerable: true, get: function () { return file_1.hasFiles; } });
|
|
29
|
+
Object.defineProperty(exports, "hasSubdirs", { enumerable: true, get: function () { return file_1.hasSubdirs; } });
|
|
30
|
+
Object.defineProperty(exports, "getJsonFileContent", { enumerable: true, get: function () { return file_1.getJsonFileContent; } });
|
|
31
|
+
Object.defineProperty(exports, "writeToJson", { enumerable: true, get: function () { return file_1.writeToJson; } });
|
|
32
|
+
var schematic_1 = require("./utils/schematic");
|
|
33
|
+
Object.defineProperty(exports, "NAMES", { enumerable: true, get: function () { return schematic_1.NAMES; } });
|
|
34
|
+
var find_module_1 = require("./utils/find-module");
|
|
35
|
+
Object.defineProperty(exports, "findModuleFromOptions", { enumerable: true, get: function () { return find_module_1.findModuleFromOptions; } });
|
|
36
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../libs/transloco/schematics-core/index.ts"],"names":[],"mappings":";;;AAAA,mDAAiE;AAAxD,4GAAA,aAAa,OAAA;AAAE,0GAAA,WAAW,OAAA;AACnC,2CAAyD;AAAhD,iHAAA,sBAAsB,OAAA;AAC/B,+CAK2B;AAJzB,uGAAA,UAAU,OAAA;AACV,4GAAA,eAAe,OAAA;AACf,yGAAA,YAAY,OAAA;AACZ,yGAAA,YAAY,OAAA;AAEd,+CAI2B;AAHzB,+GAAA,kBAAkB,OAAA;AAClB,4GAAA,eAAe,OAAA;AACf,+GAAA,kBAAkB,OAAA;AAEpB,mDAG6B;AAF3B,mHAAA,oBAAoB,OAAA;AACpB,2HAAA,4BAA4B,OAAA;AAG9B,mDAM6B;AAL3B,uHAAA,wBAAwB,OAAA;AACxB,kHAAA,mBAAmB,OAAA;AACnB,gHAAA,iBAAiB,OAAA;AACjB,kHAAA,mBAAmB,OAAA;AACnB,8HAAA,+BAA+B,OAAA;AAEjC,qCAKsB;AAJpB,gGAAA,QAAQ,OAAA;AACR,kGAAA,UAAU,OAAA;AACV,0GAAA,kBAAkB,OAAA;AAClB,mGAAA,WAAW,OAAA;AAEb,+CAA0C;AAAjC,kGAAA,KAAK,OAAA;AACd,mDAA4D;AAAnD,oHAAA,qBAAqB,OAAA"}
|