-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(admin-ui): Better error reporting for invalid translation files
Closes #292
- Loading branch information
1 parent
202f68d
commit a64f7ac
Showing
4 changed files
with
48 additions
and
7 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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
// Auto-generated by the set-version.js script. | ||
export const ADMIN_UI_VERSION = '0.10.0'; | ||
export const ADMIN_UI_VERSION = '0.10.1'; |
10 changes: 6 additions & 4 deletions
10
...ore/src/components/ui-language-switcher-dialog/ui-language-switcher-dialog.component.html
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,6 +1,8 @@ | ||
<ng-template vdrDialogTitle>{{ 'common.select-display-language' | translate }}</ng-template> | ||
|
||
<button *ngFor="let code of availableLanguages" class="btn btn-link btn-sm" (click)="setLanguage(code)"> | ||
<clr-icon [attr.shape]="code === currentLanguage ? 'dot-circle' : 'circle'"></clr-icon> | ||
{{ code | uppercase }} ({{ 'lang.' + code | translate }}) | ||
</button> | ||
<div *ngFor="let code of availableLanguages" > | ||
<button class="btn btn-link btn-sm" (click)="setLanguage(code)"> | ||
<clr-icon [attr.shape]="code === currentLanguage ? 'dot-circle' : 'circle'"></clr-icon> | ||
{{ code | uppercase }} ({{ 'lang.' + code | translate }}) | ||
</button> | ||
</div> |
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
24 changes: 22 additions & 2 deletions
24
packages/admin-ui/src/lib/core/src/providers/i18n/custom-message-format-compiler.ts
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,9 +1,29 @@ | ||
/* tslint:disable:no-console */ | ||
import { Injectable } from '@angular/core'; | ||
import { TranslateMessageFormatCompiler } from 'ngx-translate-messageformat-compiler'; | ||
import { | ||
TranslateMessageFormatCompiler, | ||
TranslateMessageFormatDebugCompiler, | ||
} from 'ngx-translate-messageformat-compiler'; | ||
|
||
/** | ||
* Work-around for Angular 9 compat. | ||
* See https://github.com/lephyrus/ngx-translate-messageformat-compiler/issues/53#issuecomment-583677994 | ||
* | ||
* Also logs errors which would otherwise get swallowed by ngx-translate. This is important | ||
* because it is quite easy to make errors in messageformat syntax, and without clear | ||
* error messages it's very hard to debug. | ||
*/ | ||
@Injectable({ providedIn: 'root' }) | ||
export class InjectableTranslateMessageFormatCompiler extends TranslateMessageFormatCompiler {} | ||
export class InjectableTranslateMessageFormatCompiler extends TranslateMessageFormatCompiler { | ||
compileTranslations(value: any, lang: string): any { | ||
try { | ||
return super.compileTranslations(value, lang); | ||
} catch (e) { | ||
console.error(`There was an error with the ${lang} translations:`); | ||
console.log(e); | ||
console.log( | ||
`Check the messageformat docs: https://messageformat.github.io/messageformat/page-guide`, | ||
); | ||
} | ||
} | ||
} |