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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@nettyapps/ntyi18n

v21.0.0

Published

The i18n library provides a comprehensive solution for managing multi-language support in Angular applications. Built on top of `@ngx-translate/core`, it offers advanced functionality for language management, translation merging, and persistent language p

Readme

Netty i18n Library

The i18n library provides a comprehensive solution for managing multi-language support in Angular applications. Built on top of @ngx-translate/core, it offers advanced functionality for language management, translation merging, and persistent language preferences.

Key Features:

  • Language persistence: Remembers user language preference via localStorage
  • Translation merging: Ability to merge with existing translations or overwrite them
  • Multi-language support: Easy to add new languages
  • Browser language detection: Automatically detects browser/OS language
  • API language codes: Maintains separate API language codes for backend communication

Installation

To add the ntyi18n library to your project, use the following command:

npm install @nettyapps/ntyi18n

Ensure @ngx-translate/core is installed as a dependency.

I18nService Usage

Initialization

Initialize the service in your root component (typically app.ts):

import { I18nService } from "@nettyapps/ntyi18n";

@Component({
  // ...
})
export class AppComponent implements OnInit {
  constructor(private i18nService: I18nService) {}

  ngOnInit() {
    this.i18nService.init(environment.defaultLanguage, environment.supportedLanguages);
  }
}

Changing Language

To programmatically change the current language:

this.i18nService.language = "Français";

Getting Current Language

To get the current language:

const currentLang = this.i18nService.language;

Adding New Languages

The library includes English (en-US) and Turkish (tr-TR) translations by default. In your main project:

  1. You can override these translations
  2. Add new languages
  3. Merge with new translations

Step 1: Create Translation File

Create a JSON file for your new language in the assets/i18n/ folder (e.g., fr-FR.json for French).

Use the same structure as existing translation files (en-US.json and tr-TR.json).

{
  "common": {
    "welcome": "Bienvenue",
    "save": "Enregistrer"
  }
}

Step 2: Update Environment Configuration

Update the environment.ts file to include the new language:

export const environment = {
  production: false,
  version: env["npm_package_version"],
  defaultLanguage: "Türkçe", // Default language
  supportedLanguages: ["Türkçe", "English", "Français"], // New language
};

Step 3: Register Translation with Application

During application initialization (typically in app.ts):

import frFR from "../assets/i18n/fr-FR.json";

constructor(private i18nService: I18nService) {
  this.i18nService.addTranslations("Français", frFR, true);
}

Dynamic Translation Merging

The addTranslations method allows you to dynamically add or update translations:

/**
 * Adds new translations or updates existing ones
 * @param lang Language code (e.g., 'English', 'Türkçe')
 * @param translations Translation JSON object
 * @param shouldMerge If true, merges with existing translations; if false, overwrites
 */
this.i18nService.addTranslations("Türkçe", trTR, true);
  • Merge (true): Combines new translations with existing ones, preserving existing keys not present in new translations

  • Overwrite (false): Completely replaces all translations for the specified language