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

@cheetah-labs/i18n

v3.0.2

Published

Locale-aware Angular router, switcher, SEO helpers and fallback util shared across cheetah sites.

Readme

@cheetah-labs/i18n

Locale-aware Angular utilities shared across all cheetah customer sites — router prefix guard, language switcher, SEO helpers and a fallback util.

公開 npm package(npmjs, scope @cheetah-labs)。 不處理 CMS 內容、不負責翻譯字串管理;只解決 i18n 共用邏輯。

Install

pnpm add @cheetah-labs/i18n

公開套件可直接安裝,不需要額外設定私有 registry。

版本相容表 (Compatibility)

| @cheetah-labs/i18n | Angular (peer) | rxjs (peer) | Node (engines) | |---|---|---|---| | 3.x | >=22.0.0 <23.0.0 | ^7.8.0 | >=22.0.0 | | 2.x | >=21.0.0 <22.0.0 | ^7.8.0 | >=22.0.0 |

每個 Angular major 對應本套件一個 major:Angular 23 支援將以下一個 major 版本提供。engines 對消費端保持寬鬆(>=22);本 repo 開發環境使用 Node 26(.nvmrc)。

API

provideI18n(config)

import { provideI18n, withLocaleRouting } from '@cheetah-labs/i18n';
import { provideRouter } from '@angular/router';

export const appConfig: ApplicationConfig = {
  providers: [
    provideI18n({
      locales: ['zh-TW', 'en'],
      defaultLocale: 'zh-TW',
      fallbackLocale: 'zh-TW',
      strategy: 'prefix',
    }),
    provideRouter(withLocaleRouting(routes)),
  ],
};

withLocaleRouting(routes)

把路由樹包裝為「每個 top-level route 都會跑 localePrefixGuard」。

  • /about → 重導 /<defaultLocale>/about
  • /fr/about(fr 不在 locales)→ 重導 /<defaultLocale>/about
  • /zh-TW/about(合法)→ 通過

<i18n-switcher />

<i18n-switcher />

Standalone component,列出所有 locale,點擊切換 URL;自帶 aria-label="Language switcher" / aria-current

取得目前語系

import { CURRENT_LOCALE, LocaleResolver } from '@cheetah-labs/i18n';

// 注入時快照 — 不會隨後續導航更新
const locale = inject(CURRENT_LOCALE);

// reactive — 瀏覽器端切換語系後會跟著變
const locale$ = inject(LocaleResolver).current$();

CURRENT_LOCALE注入當下解析的一次性快照。SSR 每個 request 一個 injector,直接用即可;瀏覽器端長駐應用中,之後切換語系不會改變已注入的值,reactive 場景請改用 LocaleResolver.current$()

pickLocalized(field, locale, fallback)

import { pickLocalized } from '@cheetah-labs/i18n';

pickLocalized({ 'zh-TW': '你好', en: 'Hello' }, 'en', 'zh-TW'); // 'Hello'
pickLocalized({ 'zh-TW': '你好' },                'en', 'zh-TW'); // '你好'
pickLocalized('plain string',                     'en', 'zh-TW'); // 'plain string'
pickLocalized(undefined,                          'en', 'zh-TW'); // undefined

限制pickLocalized 以「值是否為 plain object」判斷 i18n 欄位。若 T 本身是物件(非 locale map),會被誤判為 i18n map 而回傳 undefined;物件型內容請自行依 locale key 存取。

SEO

import { HreflangService, CanonicalService } from '@cheetah-labs/i18n';

constructor() {
  inject(HreflangService).set('https://example.com/{locale}/about');
  inject(CanonicalService).set('https://example.com/zh-TW/about');
}

HreflangService 自動加入 x-default,下次呼叫前會清掉舊 tag。

SSR locale resolver

// server.ts (Express)
import { withSsrLocaleResolver, provideI18n } from '@cheetah-labs/i18n';

app.use('*', (req, res) => {
  bootstrapApplication(AppComponent, {
    providers: [
      provideI18n({ locales: ['zh-TW', 'en'], defaultLocale: 'zh-TW' }),
      withSsrLocaleResolver(req),
    ],
  });
});

CURRENT_LOCALE 解析優先序:

  • SSRwithSsrLocaleResolver):URL prefix → Accept-Language → defaultLocale
  • 瀏覽器provideI18n 內建):URL prefix → defaultLocale

Develop

pnpm install
pnpm test
pnpm lint
pnpm type-check
pnpm build         # ng-packagr → ./dist

Publish

版本管理由 release-please 自動化:

  1. conventional commits merge 進 main
  2. release-please 自動開 / 更新 Release PR(version bump + CHANGELOG.md
  3. Release PR merge 後自動打 vX.Y.Z tag 並建立 GitHub Release
  4. tag 觸發 .github/workflows/publish.yml → 驗證 tag 與 package.json 版本一致 → publish 到 npmjs

不手動 bump version、不手動編輯 CHANGELOG.md、不手動打 tag。發佈驗證使用 npm Trusted Publishing(OIDC,需在 npmjs 套件設定對應此 repo/workflow 的 Trusted Publisher);workflow 未接 token fallback,OIDC 是唯一發佈憑證。本 repo 為 private、npm 套件為 public——npm 對 private repo 不會產生 provenance attestations,此為專案定案的發佈模式。

License

Apache-2.0