{"_id":"@1-/i18nyml","_rev":"2-5d079bece9dca78cb874104070dd467a","name":"@1-/i18nyml","dist-tags":{"latest":"0.1.1"},"versions":{"0.1.0":{"name":"@1-/i18nyml","version":"0.1.0","keywords":[],"author":{"name":"x-at-01@googlegroups.com"},"license":"MulanPSL-2.0","_id":"@1-/i18nyml@0.1.0","maintainers":[{"name":"i18n-now","email":"i18n.site@gmail.com"}],"homepage":"https://github.com/webc-site/npm/tree/main/i18nyml","bugs":{"url":"https://github.com/webc-site/npm/issues"},"dist":{"shasum":"75100e68810cf37482e958e2b624437c3b4fa893","tarball":"https://registry.npmjs.org/@1-/i18nyml/-/i18nyml-0.1.0.tgz","fileCount":3,"integrity":"sha512-KCw6EGIxog9OVJQGauVifDS3aSkb8FVx1k3IhJrWqGqgvSveh5d5yJN1HHyI2KGNELc0GVjZToBbFsrwIbEG7w==","signatures":[{"sig":"MEUCIQCqHtphJXzQZvODe4ilymfmLUP+NzGHzbLsrCvhZxRgdAIgSYHyfsrRrUh8b1uktFiZN87I4iSTgTq92O4SoBn5jHc=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":5482},"type":"module","exports":{".":"./_.js","./*":"./*"},"_npmUser":{"name":"i18n-now","email":"i18n.site@gmail.com"},"repository":{"url":"git+https://github.com/webc-site/npm.git","type":"git"},"_npmVersion":"11.16.0","description":"[English](#en) | [中文](#zh)","directories":{},"_nodeVersion":"26.2.0","dependencies":{"@1-/yml":"^0.1.0","@1-/oslang":"^0.1.2"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/i18nyml_0.1.0_1783084306469_0.49546368096657334","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@1-/i18nyml","version":"0.1.1","description":"Load YAML localization files by system language preference. 根据系统语言偏好加载 YAML 本地化文件","keywords":["i18n","localization","yaml","internationalization","locale"],"homepage":"https://github.com/webc-site/npm/tree/main/i18nyml","license":"MulanPSL-2.0","author":{"name":"x-at-01@googlegroups.com"},"repository":{"type":"git","url":"git+https://github.com/webc-site/npm.git"},"type":"module","exports":{".":"./_.js","./*":"./*"},"dependencies":{"@1-/oslang":"^0.1.2","@1-/yml":"^0.1.0"},"_id":"@1-/i18nyml@0.1.1","bugs":{"url":"https://github.com/webc-site/npm/issues"},"_nodeVersion":"26.2.0","_npmVersion":"11.16.0","dist":{"integrity":"sha512-YAdS2C6tk1sOibEQpfwk6Rm+nPVu4uGsSomCGdHw+edJzmxzwPamZ8iKyv91/Mh3mshj8QPu0z5uaPwNFxgmQA==","shasum":"e446c1d6892f28b42fe8fc3ce1a6411edb9988e1","tarball":"https://registry.npmjs.org/@1-/i18nyml/-/i18nyml-0.1.1.tgz","fileCount":3,"unpackedSize":6775,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCICdcSm784bAffD2Oescayu8gI5300fIp2Y8j3jgIA1GyAiEAg5okb1ZAbTqCOqqpsK0oy6ArOvsr0F3HWDRJUhu6Vqc="}]},"_npmUser":{"name":"i18n-now","email":"i18n.site@gmail.com"},"directories":{},"maintainers":[{"name":"i18n-now","email":"i18n.site@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/i18nyml_0.1.1_1783084535499_0.7611868735165856"},"_hasShrinkwrap":false}},"time":{"created":"2026-07-03T13:11:46.275Z","modified":"2026-07-03T13:15:35.793Z","0.1.0":"2026-07-03T13:11:46.592Z","0.1.1":"2026-07-03T13:15:35.653Z"},"bugs":{"url":"https://github.com/webc-site/npm/issues"},"author":{"name":"x-at-01@googlegroups.com"},"license":"MulanPSL-2.0","homepage":"https://github.com/webc-site/npm/tree/main/i18nyml","keywords":["i18n","localization","yaml","internationalization","locale"],"repository":{"type":"git","url":"git+https://github.com/webc-site/npm.git"},"description":"Load YAML localization files by system language preference. 根据系统语言偏好加载 YAML 本地化文件","maintainers":[{"name":"i18n-now","email":"i18n.site@gmail.com"}],"readme":"[English](#en) | [中文](#zh)\n\n---\n\n<a id=\"en\"></a>\n# @1-/i18nyml : Load YAML localization files by system language preference\n\n- [@1-/i18nyml : Load YAML localization files by system language preference](#1-i18nyml-load-yaml-localization-files-by-system-language-preference)\n  - [Functionality](#functionality)\n  - [Usage demonstration](#usage-demonstration)\n  - [Design思路](#design思路)\n  - [Technology stack](#technology-stack)\n  - [Code structure](#code-structure)\n  - [Historical context](#historical-context)\n  - [About](#about)\n\n## Functionality\n\nLoad YAML localization files according to system language preferences. Automatically detect available locales and load the most appropriate translation file based on the user's system language settings, supporting environment variable priority order (LANGUAGE, LC_ALL, LC_MESSAGES, LANG) and Intl API fallback.\n\n## Usage demonstration\n\n```bash\nnpm install @1-/i18nyml\n```\n\n```javascript\nimport i18nyml from \"@1-/i18nyml\";\n\n// Load messages.yml from locales directory\nconst messages = i18nyml(\"./locales\", \"messages\");\nconsole.log(messages);\n```\n\nDirectory structure expected:\n\n```\nlocales/\n├── en/\n│   └── messages.yml\n├── zh-CN/\n│   └── messages.yml\n├── zh/\n│   └── messages.yml\n└── ja/\n    └── messages.yml\n```\n\n## Design思路\n\nThe library implements a precise three-phase locale matching strategy:\n\n1. Read language preferences from environment variables LANGUAGE, LC_ALL, LC_MESSAGES, LANG\n2. Fall back to Intl.DateTimeFormat().resolvedOptions().locale\n3. Final default to \"en\"\n\nEach phase's language code is normalized (e.g., \"zh_CN\" → \"zh-cn\") before exact matching against available locales.\n\n![](https://fastly.jsdelivr.net/gh/webc-fs/-@9a/lk-8bYSVv43rNhEQUBcg.svg)\n\n## Technology stack\n\n- Node.js runtime\n- @1-/oslang for language detection and preference ordering\n- @1-/yml for YAML parsing\n- Standard Node.js filesystem APIs\n\n## Code structure\n\n```\nsrc/\n└── _.js          # Main export function implementing locale loading logic\n```\n\nDependencies:\n\n- @1-/oslang: Language detection and normalization (via all.js and match.js)\n- @1-/yml: Lightweight YAML parser (via load.js and loads.js)\n\n## Historical context\n\nYAML emerged in 2001 as a human-readable data serialization format designed to be more intuitive than XML or JSON for configuration files. Its emphasis on readability made it particularly suitable for localization files where translators need to work with plain text. The i18nyml library builds on this foundation by combining YAML's simplicity with modern JavaScript's internationalization capabilities to provide a concise YAML localization file loading solution, using a functional programming paradigm with no external dependencies beyond Node.js built-in modules.\n\n## About\n\nThis library is developed by [WebC.site](https://webc.site).\n\n[WebC.site](https://webc.site): A new paradigm of web development for AI\n\n\n---\n\n<a id=\"zh\"></a>\n# @1-/i18nyml : 根据系统语言偏好加载 YAML 本地化文件\n\n- [@1-/i18nyml : 根据系统语言偏好加载 YAML 本地化文件](#1-i18nyml-根据系统语言偏好加载-yaml-本地化文件)\n  - [功能介绍](#功能介绍)\n  - [使用演示](#使用演示)\n  - [设计思路](#设计思路)\n  - [技术栈](#技术栈)\n  - [代码结构](#代码结构)\n  - [历史故事](#历史故事)\n  - [关于](#关于)\n\n## 功能介绍\n\n根据系统语言偏好自动加载 YAML 本地化文件。检测可用区域设置并基于用户系统语言设置加载最合适的翻译文件，支持环境变量 LANGUAGE, LC_ALL, LC_MESSAGES, LANG 的优先级顺序，以及 Intl API 回退。\n\n## 使用演示\n\n```bash\nnpm install @1-/i18nyml\n```\n\n```javascript\nimport i18nyml from \"@1-/i18nyml\";\n\n// 从 locales 目录加载 messages.yml\nconst messages = i18nyml(\"./locales\", \"messages\");\nconsole.log(messages);\n```\n\n预期目录结构：\n\n```\nlocales/\n├── en/\n│   └── messages.yml\n├── zh-CN/\n│   └── messages.yml\n├── zh/\n│   └── messages.yml\n└── ja/\n    └── messages.yml\n```\n\n## 设计思路\n\n该库采用精确的三阶段区域设置匹配策略：\n\n1. 从环境变量 LANGUAGE, LC_ALL, LC_MESSAGES, LANG 读取语言偏好\n2. 回退到 Intl.DateTimeFormat().resolvedOptions().locale\n3. 最终默认为 \"en\"\n\n每个阶段的语言代码经过标准化处理（如 \"zh_CN\" → \"zh-cn\"），然后与可用区域设置进行精确匹配。\n\n![](https://fastly.jsdelivr.net/gh/webc-fs/-@R_/Y3OlvnVGjFxzdxx7e8rA.svg)\n\n## 技术栈\n\n- Node.js 运行时\n- @1-/oslang 用于语言检测与偏好排序\n- @1-/yml 用于 YAML 解析\n- 标准 Node.js 文件系统 API\n\n## 代码结构\n\n```\nsrc/\n└── _.js          # 主导出函数，实现区域设置加载逻辑\n```\n\n依赖项：\n\n- @1-/oslang：语言检测与规范化（通过 all.js 和 match.js）\n- @1-/yml：轻量级 YAML 解析器（通过 load.js 和 loads.js）\n\n## 历史故事\n\nYAML 于 2001 年问世，作为一种人类可读的数据序列化格式，旨在比 XML 或 JSON 更直观易用。其强调可读性的特点使其特别适合本地化文件，因为译员需要直接处理纯文本。i18nyml 库在此基础上结合了现代 JavaScript 的国际化能力，提供简洁的 YAML 本地化文件加载方案，采用函数式编程范式，无外部依赖，仅使用 Node.js 内置模块。\n\n## 关于\n\n本库由 [WebC.site](https://webc.site) 开发。\n\n[WebC.site](https://webc.site) : 面向人工智能的网站开发新范式\n\n","readmeFilename":"README.md"}