Plugin for ngx-translate that helps debug translation keys π
Here's the DEMO or edit on StackBlitz
Make sure you have installed @ngx-translate library
- Use npm to install the package
npm i ngx-translate-debug
- Add custom parser for
TranslateModule
import{NgxTranslateDebugParser}from'ngx-translate-debug';
@NgModule({// ...imports: [// ...TranslateModule.forRoot({// ...parser: {provide: TranslateParser,useClass: NgxTranslateDebugParser},// <--- ADD THIS LINE}),]})- Inject
NgxTranslateDebugServicein component's constructor
import{NgxTranslateDebugService}from'ngx-translate-debug';exportclassAppComponent{constructor(// ...publictranslateDebugService: NgxTranslateDebugService// <--- ADD THIS LINE){// ...}}- Use methods of
NgxTranslateDebugService
<buttontype="button" (click)="translateDebugService.toggleDebug()">
Toggle debug mode
</button><buttontype="button" (click)="translateDebugService.enableDebug()">
Enable debug mode
</button><buttontype="button" (click)="translateDebugService.disableDebug()">
Disable debug mode
</button>- The plugin records the last state in
window.localStorage['ngx-translate-debug']. You can change key by providing config in root module
import{NGX_TRANSLATE_DEBUG_CONFIG}from'ngx-translate-debug';
@NgModule({// ...providers: [// ...{provide: NGX_TRANSLATE_DEBUG_CONFIG,useValue: {localStorageKey: 'any-custom-key',},},],})exportclassAppModule{}