Registry /
productivity / angular-translate-cache
Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
TranslateCacheModule
✓ import { TranslateCacheModule } from 'angular-translate-cache';
✗ import { TranslateCacheModule } from '@angular-translate/core';
This module is provided by angular-translate-cache, not the core library.
TranslateCacheService
✓ import { TranslateCacheService } from 'angular-translate-cache';
✗ const TranslateCacheService = require('angular-translate-cache').TranslateCacheService;
The library is ESM-only; CommonJS require may not work with some bundlers.
TranslateCacheSettings
✓ import { TranslateCacheSettings } from 'angular-translate-cache';
✗ import { TranslateCacheSettings } from 'angular-translate-cache/settings';
All exports are from the main package entry point.
Setup angular-translate-cache with standalone app, configure caching via forRoot, and initialize in AppComponent.
import { importProvidersFrom } from '@angular/core';
import { bootstrapApplication } from '@angular/platform-browser';
import { TranslateModule, TranslateService } from '@angular-translate/core';
import { TranslateCacheModule, TranslateCacheSettings, TranslateCacheService } from 'angular-translate-cache';
import { AppComponent } from './app/app.component';
bootstrapApplication(AppComponent, {
providers: [
importProvidersFrom(
TranslateModule.forRoot(),
TranslateCacheModule.forRoot({
cacheService: {
provide: TranslateCacheService,
useFactory: (translateService: TranslateService, translateCacheSettings: TranslateCacheSettings) => {
return new TranslateCacheService(translateService, translateCacheSettings);
},
deps: [TranslateService, TranslateCacheSettings],
},
cacheName: 'lang',
cacheMechanism: 'Cookie',
})
),
],
});
// In AppComponent:
import { Component } from '@angular/core';
import { TranslateService } from '@angular-translate/core';
import { TranslateCacheService } from 'angular-translate-cache';
@Component({
selector: 'app-root',
standalone: true,
template: `<div>{{ 'HELLO' | translate }}</div>`,
})
export class AppComponent {
constructor(
private translateService: TranslateService,
private translateCacheService: TranslateCacheService
) {
this.translateService.setDefaultLang('en');
this.translateCacheService.init();
}
}
Errors
Common errors & fixes
Error: Angular JIT compilation failed: 'TranslateCacheModule' is not a function
Forgot to call .forRoot() on TranslateCacheModule.
fixUse TranslateCacheModule.forRoot({...}) instead of TranslateCacheModule in imports. NullInjectorError: No provider for TranslateCacheService!
TranslateCacheService not provided in root injector.
fixAdd the cacheService provider inside TranslateCacheModule.forRoot().
TypeError: Cannot read property 'init' of undefined
TranslateCacheService instance not available in component.
fixEnsure TranslateCacheService is provided via Angular DI (e.g., in AppComponent constructor).
Audit
Dependencies
@angular-translate/corerequiredPeer dependency: required to use TranslateService and TranslateModule.
@angular/corerequiredPeer dependency: Angular framework.