-
-
Notifications
You must be signed in to change notification settings - Fork 585
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(module): modularize everything and adding forChild
- Loading branch information
Showing
13 changed files
with
397 additions
and
296 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import {TranslateService} from "./translate.service"; | ||
import {Injectable} from "@angular/core"; | ||
|
||
export interface MissingTranslationHandlerParams { | ||
/** | ||
* the key that's missing in translation files | ||
* | ||
* @type {string} | ||
*/ | ||
key: string; | ||
|
||
/** | ||
* an instance of the service that was unable to translate the key. | ||
* | ||
* @type {TranslateService} | ||
*/ | ||
translateService: TranslateService; | ||
|
||
/** | ||
* interpolation params that were passed along for translating the given key. | ||
* | ||
* @type {Object} | ||
*/ | ||
interpolateParams?: Object; | ||
} | ||
|
||
export abstract class MissingTranslationHandler { | ||
/** | ||
* A function that handles missing translations. | ||
* | ||
* @abstract | ||
* @param {MissingTranslationHandlerParams} params context for resolving a missing translation | ||
* @returns {any} a value or an observable | ||
* If it returns a value, then this value is used. | ||
* If it return an observable, the value returned by this observable will be used (except if the method was "instant"). | ||
* If it doesn't return then the key will be used as a value | ||
*/ | ||
abstract handle(params: MissingTranslationHandlerParams): any; | ||
} | ||
|
||
/** | ||
* This handler is just a placeholder that does nothing, in case you don't need a missing translation handler at all | ||
*/ | ||
@Injectable() | ||
export class FakeMissingTranslationHandler implements MissingTranslationHandler { | ||
handle(params: MissingTranslationHandlerParams): string { | ||
return params.key; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import {Observable} from "rxjs/Observable"; | ||
import {Injectable} from "@angular/core"; | ||
|
||
export abstract class TranslateLoader { | ||
abstract getTranslation(lang: string): Observable<any>; | ||
} | ||
|
||
/** | ||
* This loader is just a placeholder that does nothing, in case you don't need a loader at all | ||
*/ | ||
@Injectable() | ||
export class TranslateFakeLoader extends TranslateLoader { | ||
getTranslation(lang: string): Observable<any> { | ||
return Observable.of({}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export class TranslateStore { | ||
|
||
} |
Oops, something went wrong.