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

@wawjs/ngx-translate

v21.3.2

Published

Angular language and runtime translation package from Web Art Work.

Readme

ngx-translate

Angular language and runtime translation package from Web Art Work.

ngx-translate is SSR-safe and focused on two features:

  • LanguageService plus provideLanguage(...) for active language state, defaults, registry management, and optional persistence
  • TranslateService plus provideTranslate(...) and TranslateDirective for signal-based runtime translations

License

MIT

Installation

npm i --save @wawjs/ngx-translate

Usage

import { provideTranslate } from '@wawjs/ngx-translate';

export const appConfig = {
	providers: [
		provideTranslate({
			defaultLanguage: 'en',
			language: 'en',
			languages: ['en', 'de', 'fr'],
			folder: '/i18n/',
			folders: ['/i18n/articles/', '/i18n/common/'],
		}),
	],
};

Language-Only Bootstrap

import { provideLanguage } from '@wawjs/ngx-translate';

export const appConfig = {
	providers: [
		provideLanguage({
			defaultLanguage: 'en',
			languages: ['en', 'de', 'fr'],
		}),
	],
};

Available Features

| Name | Description | | ------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------- | | LanguageService | Active language state, registry management, validation, and persistence | | TranslateService | Signal-based runtime translation loading and updates | | TranslateDirective | Directive that translates explicit text, inline text, and attributes | | provideLanguage, provideTranslate | Environment providers for bootstrap | | Language, LanguageInput, ProvideLanguageConfig, ProvideTranslateConfig, Translate | Public types |

Language Service

LanguageService manages the active language, default language, available languages, and optional persistence.

Methods

  • init(config?)
  • language(): string
  • defaultLanguage(): string
  • allLanguages(): Language[]
  • languages(): Language[]
  • getLanguage(code: string)
  • hasLanguage(code: string): boolean
  • setLanguages(languages, syncCurrentLanguage?)
  • setLanguage(code: string): Promise<boolean>

Translate Service

TranslateService manages runtime translations and updates translation signals reactively.

Features

  • inline translations through config
  • file loading from /i18n/{language}.json
  • optional multi-folder loading such as /i18n/common/{language}.json and /i18n/articles/{language}.json
  • signal-based translation updates
  • source-text fallback when no translation exists
  • optional persisted language selection

Methods

  • init(config?)
  • language()
  • defaultLanguage()
  • setLanguage(language: string)
  • loadTranslations(language: string)
  • loadExtraTranslations(paths: string[], options?)
  • loadExtraTranslation(path: string, options?)
  • translate(text: string)
  • setMany(translations: Translate[])
  • setOne(translation: Translate)
  • get()

Example:

import { inject } from '@angular/core';
import { TranslateService } from '@wawjs/ngx-translate';

const _translateService = inject(TranslateService);

const title = _translateService.translate('Create project');

void _translateService.setLanguage('de');

Route/Page Extra JSON Bundles

You can merge additional JSON translation files for a specific page without replacing the base language file.

import { ActivatedRoute } from '@angular/router';
import { inject } from '@angular/core';
import { TranslateService } from '@wawjs/ngx-translate';

const _route = inject(ActivatedRoute);
const _translateService = inject(TranslateService);

const slug = _route.snapshot.paramMap.get('slug') || '';

await _translateService.loadExtraTranslations(['/i18n/articles/', `/i18n/article/${slug}`]);

await _translateService.loadExtraTranslation('/i18n/articles/');

Notes:

  • For folder-style paths, /{language}.json is appended automatically.
  • {language} and :language placeholders are replaced automatically.
  • Existing translations are kept by default and then overridden by later files.
  • Extra translation URLs are cached per language and are not fetched again on repeat calls.
  • Pass replace: true to replace cached translations for that language with only the loaded files.
  • Pass forceReload: true to refetch URLs that were already cached.

Translate Directive

<h1 translate>Create project</h1>
<button translate>Save</button>
<h2 translate="Create project"></h2>
<span
	[translate]="{
		title: 'This is hello world title',
		content: 'hello world',
		ariaLabel: 'hello world label',
	}"
></span>

Use content for the host text. Other object keys are translated and written as attributes; camelCase keys such as ariaLabel are written as dash-case attributes such as aria-label.

Notes

  • Language persistence uses guarded browser storage access and is skipped during SSR.
  • Translation payloads can come from inline config, folder, folders, and route/page extra JSON files.
  • Missing translations safely fall back to the source text.

AGENTS.md

Copy this into your project AGENTS.md when using ngx-translate:

- This project uses `ngx-translate`, an Angular utility library for runtime language and translation management.
- Prefer bootstrapping with `provideTranslate({...})` when translations are needed, or `provideLanguage({...})` for language-only state.
- Register app translations with `provideTranslate(...)` and use `TranslateService` or `TranslateDirective` instead of creating a parallel translation bootstrap path.
- Prefer `LanguageService` for active language state, validation, defaults, and persistence before adding app-specific language utilities.
- Keep SSR-safe behavior intact. Do not add unguarded direct access to browser storage for language persistence when the package already handles it.