npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@ngfly/translate-db

v0.0.4

Published

Angular translation library using IndexedDB for storage

Readme

@ngfly/translate-db

A robust, offline-first translation library for Angular applications with IndexedDB support.

Features

  • 🔄 Dynamic language switching
  • 💾 Offline-first with IndexedDB storage
  • 🚀 Reactive translations using Observables
  • 🔍 Type-safe translation keys
  • 📱 Memory efficient with automatic cleanup
  • 🎯 Zero dependencies (except Angular core)

Installation

npm install @ngfly/translate-db

Quick Start

1. Configure in app.config.ts

import { ApplicationConfig } from '@angular/core';
import { provideTranslate } from '@ngfly/translate-db';

export const appConfig: ApplicationConfig = {
  providers: [
    // ... other providers
    provideTranslate({
      projectId: 'your-project-id',
      endpoint: 'https://your-api-endpoint',
      defaultLang: 'en',
      apiKey: 'optional-api-key',
      acceptedLanguages: ['en', 'fr', 'it', 'de', '...'],
    }),
  ],
};

2. Use in Components

import { Component } from '@angular/core';
import { TranslatePipe, TranslateService } from '@ngfly/translate-db';

@Component({
  selector: 'app-root',
  template: `
    <div>
      <!-- Using the pipe -->
      <p>{{ 'WELCOME_MESSAGE' | appTranslate | async }}</p>
      
      <!-- Language switcher -->
      <button (click)="changeLanguage('en')">English</button>
      <button (click)="changeLanguage('fr')">Français</button>
    </div>
  `,
  imports: [TranslatePipe],
  standalone: true
})
export class AppComponent {
  constructor(private translate: TranslateService) {}

  changeLanguage(lang: string): void {
    this.translate.setLanguage(lang);
  }
}

3. Using the Translation Pipe

The appTranslate pipe is designed to be used with Angular's async pipe:

<!-- Basic usage -->
{{ 'TRANSLATION_KEY' | appTranslate | async }}

<!-- With variables -->
{{ dynamicKey | appTranslate | async }}

<!-- In attributes -->
<div [title]="'TOOLTIP_KEY' | appTranslate | async">

{{ 'LABEL_HELLO' | appTranslate: { name: 'DevFlow' } | async }}

API Reference

TranslateService

The core service for handling translations.

class TranslateService {
  // Get current language
  get currentLanguage(): string;
  
  // Get list of supported languages
  get supportedLanguages(): string[];
  
  // Change language
  async setLanguage(lang: string): Promise<void>;
  
  // Get translation synchronously
  instant(key: string): string;
  
  // Get translation asynchronously
  async translate(key: string): Promise<string>;
  
  // Observable for language changes
  get onLangChange(): Observable<string>;
}

Configuration Options

interface TranslationConfig {
  projectId: string;                // Your project identifier
  endpoint: string;                 // API endpoint for fetching translations
  defaultLang: string;              // Default language to use
  apiKey?: string;                  // Optional API key for authentication
  acceptedLanguages: string[];      // List of supported languages
}

Memory Management

The library is designed to be memory efficient:

  • Uses Angular's async pipe for automatic subscription cleanup
  • No memory leaks as subscriptions are properly managed
  • Efficient change detection through Observable pattern
  • IndexedDB for offline storage without memory overhead

Performance Considerations

  • Translations are cached in IndexedDB
  • Change detection only triggers when needed
  • Lazy loading of translations
  • Efficient pipe implementation with minimal overhead

Browser Support

  • All modern browsers with IndexedDB support
  • Fallback mechanism for older browsers
  • Tested on latest Chrome, Firefox, Safari, and Edge

Contributing

Contributions are welcome! Please read our contributing guidelines before submitting pull requests.

License

MIT License - see LICENSE file for details