-
-
Notifications
You must be signed in to change notification settings - Fork 578
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): support for Angular 6 and RxJS 6
Fixes #816 BREAKING CHANGE: The library is now compatible with Angular 6+ and RxJS 6+. If you need to use Angular 5, please stay on version 9.1.1. If you need to use RxJS 5, update to 5.6 and use the rxjs-compat library (see [the RxJS update guide](https://docs.google.com/document/d/12nlLt71VLKb-z3YaSGzUfx6mJbc34nsMXtByPUN35cg/preview#))
- Loading branch information
Showing
25 changed files
with
2,669 additions
and
2,613 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ coverage | |
bundles | ||
build | ||
dist | ||
dist.tgz | ||
|
||
################# | ||
## JetBrains | ||
|
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
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 |
---|---|---|
@@ -1,49 +1,42 @@ | ||
import {TranslateService} from "./translate.service"; | ||
import {Injectable} from "@angular/core"; | ||
import {TranslateService} from "./translate.service"; | ||
|
||
export interface MissingTranslationHandlerParams { | ||
/** | ||
* the key that's missing in translation files | ||
* | ||
* @type {string} | ||
*/ | ||
key: string; | ||
/** | ||
* the key that's missing in translation files | ||
*/ | ||
key: string; | ||
|
||
/** | ||
* an instance of the service that was unable to translate the key. | ||
* | ||
* @type {TranslateService} | ||
*/ | ||
translateService: TranslateService; | ||
/** | ||
* an instance of the service that was unable to translate the key. | ||
*/ | ||
translateService: TranslateService; | ||
|
||
/** | ||
* interpolation params that were passed along for translating the given key. | ||
* | ||
* @type {Object} | ||
*/ | ||
interpolateParams?: Object; | ||
/** | ||
* interpolation params that were passed along for translating the given key. | ||
*/ | ||
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; | ||
/** | ||
* A function that handles missing translations. | ||
* | ||
* @param params context for resolving a missing translation | ||
* @returns 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; | ||
} | ||
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 |
---|---|---|
@@ -1,20 +1,21 @@ | ||
import {Injectable} from "@angular/core"; | ||
|
||
export abstract class TranslateCompiler { | ||
abstract compile(value: string, lang: string): string | Function; | ||
abstract compileTranslations(translations: any, lang: string): any; | ||
abstract compile(value: string, lang: string): string | Function; | ||
|
||
abstract compileTranslations(translations: any, lang: string): any; | ||
} | ||
|
||
/** | ||
* This compiler is just a placeholder that does nothing, in case you don't need a compiler at all | ||
*/ | ||
@Injectable() | ||
export class TranslateFakeCompiler extends TranslateCompiler { | ||
compile(value: string, lang: string): string | Function { | ||
return value; | ||
} | ||
compile(value: string, lang: string): string | Function { | ||
return value; | ||
} | ||
|
||
compileTranslations(translations: any, lang: string): any { | ||
return translations; | ||
} | ||
compileTranslations(translations: any, lang: string): any { | ||
return translations; | ||
} | ||
} |
Oops, something went wrong.