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

@1-/oslang

v0.1.2

Published

OS language detection utility. 操作系统语言检测工具

Readme

English | 中文


@1-/oslang : OS language detection utility

Functionality

Detects user's preferred language from operating system environment variables and browser/system locale settings, with normalization and hierarchical matching support. Implements multi-level fallback (e.g., zh-CNzh) to reliably select the best-fit language in internationalized applications.

Usage demonstration

npm install @1-/oslang
import oslang from "@1-/oslang";
import match from "@1-/oslang/match.js";

// Get all normalized, deduplicated language tags, including parent languages
console.log([...oslang]); // ['en-US', 'en', 'zh-CN', 'zh']

// Match against a list of available languages
const available = ["en", "zh", "ja", "ko"];
const preferred = match(available).next().value;
console.log(preferred); // 'zh' (if system is zh-CN) or undefined (if no match)

Design rationale

The library uses a deterministic priority order: sources are tried sequentially, then results are normalized and expanded to include parent locales:

Technology stack

  • Node.js runtime (ESM modules)
  • Standard JavaScript (zero external dependencies)
  • Intl.DateTimeFormat().resolvedOptions().locale API
  • node:process.env for environment variable access

Code structure

src/
├── _.js        # Main export: yields raw language sources (env + Intl + fallback)
├── all.js      # Normalized set: deduplicated, lowercase, hyphen-separated, with auto-added parent languages (e.g., en-US → en)
├── match.js    # Matching function: returns iterator yielding first matched item (original input)
└── parse.js    # Normalization utility: strips encoding suffixes, replaces `_` with `-`, lowercases

Historical context

The POSIX standard, first published in 1988 (IEEE Std 1003.1-1988), formally standardized LC_* environment variables (e.g., LC_MESSAGES, LC_TIME) to provide portable localization on Unix systems. LANG served as the default fallback, while LANGUAGE was later extended by GNU to support ordered language preference lists (e.g., zh_CN:zh_TW). This library carries forward that four-decade tradition, re-implementing its core semantics in modern JavaScript.

About

This library is developed by WebC.site.

WebC.site: A new paradigm of web development for AI


@1-/oslang : 操作系统语言检测工具

功能介绍

从操作系统环境变量与浏览器/系统区域设置中检测用户首选语言,提供标准化处理与层级匹配能力。支持多级语言回退(如 zh-CNzh),确保在国际化应用中可靠选择最适配的语言。

使用演示

npm install @1-/oslang
import oslang from "@1-/oslang";
import match from "@1-/oslang/match.js";

// 获取所有已标准化、去重且含父语言的语言标识符
console.log([...oslang]); // ['en-US', 'en', 'zh-CN', 'zh']

// 在可用语言列表中匹配最优项
const available = ["en", "zh", "ja", "ko"];
const preferred = match(available).next().value;
console.log(preferred); // 'zh'(若系统为 zh-CN)或 undefined(若无匹配)

设计思路

本库采用确定性优先级策略,按顺序尝试多种来源,并对结果进行标准化与层级扩展:

技术栈

  • Node.js 运行时(ESM 模块)
  • 标准 JavaScript(无外部依赖)
  • Intl.DateTimeFormat().resolvedOptions().locale API
  • node:process.env 环境读取

代码结构

src/
├── _.js        # 主导出:生成原始语言源(环境变量 + Intl + fallback)
├── all.js      # 标准化集:去重、小写、短横线分隔,并自动添加父语言(如 en-US → en)
├── match.js    # 匹配函数:返回迭代器,yield 首个匹配项(原始输入项)
└── parse.js    # 标准化工具:移除编码后缀、下划线转短横线、转小写

历史故事

POSIX 标准于 1988 年首次发布(IEEE Std 1003.1-1988),正式将 LC_* 环境变量(如 LC_MESSAGES, LC_TIME)纳入规范,为 Unix 系统提供可移植的本地化机制。LANG 变量作为默认兜底,LANGUAGE 则被 GNU 系统扩展用于多语言优先级列表(如 zh_CN:zh_TW)。本库延续这一四十年传统,在现代 JavaScript 环境中轻量复现其核心语义。

关于

本库由 WebC.site 开发。

WebC.site : 面向人工智能的网站开发新范式