@bbc/psammead-locales

中文文档
5.0.7发布于 2021/05/27Apache-2.0近 30 天下载 6578

A collection of locale configs, used in BBC World Service sites

原始使用文档
文档目录10 节
  1. Exports
  2. Moment locales
  3. Numerals
  4. Installation
  5. Usage
  6. Moment locales
  7. Numerals
  8. Contributing
  9. Code of Conduct
  10. License

psammead-locales - Known Vulnerabilities Dependency Status peerDependencies Status GitHub license npm version PRs Welcome

This package provides a collection of locale configs, used in BBC World Service sites.

Exports

Moment locales

The following Moment.js locales have been added as they do not exist upstream:

  • /moment/am - locale override for Amharic
  • /moment/ha - locale for Hausa
  • /moment/ig - locale for Igbo
  • /moment/om - locale override for Afaan Oromoo
  • /moment/pcm - locale for Pidgin
  • /moment/ps - locale for Pashto
  • /moment/rw - locale for Gahuza
  • /moment/so - locale for Somali
  • /moment/ti - locale for Tigrinya

The following locales have overrides to meet BBC World Service requirements where these differ from the upstream locale. Note that importing them will also cause the upstream locale to be loaded.

  • /moment/ar - locale override for Arabic
  • /moment/az - locale override for Azeri
  • /moment/bn - locale override for Bengali
  • /moment/es - locale override for Spanish (Mundo)
  • /moment/gu - locale override for Gujarati
  • /moment/hi - locale override for Hindi
  • /moment/ky - locale override for Kyrgyz
  • /moment/mr - locale override for Marathi
  • /moment/ne - locale override for Nepali
  • /moment/pa-in - locale override for Punjabi
  • /moment/pt-br - locale override for Brasil
  • /moment/ru - locale override for Russian
  • /moment/si - locale override for Sinhala
  • /moment/sr - locale override for Serbian
  • /moment/sr-cyrl - locale override for Serbian Cyrillic
  • /moment/sw - locale override for Swahili
  • /moment/ta - locale override for Tamil
  • /moment/th - locale override for Thai
  • /moment/uk - locale override for Ukrainian
  • /moment/ur - locale override for Urdu
  • /moment/uz - locale override for Uzbek
  • /moment/yo - locale override for Yoruba

Numerals

Numeral systems

/numerals - Numerals in several different number systems, e.g. Bengali, Burmese, Eastern Arabic, Western Arabic. This can be used for localised numbers for components. Returns arrays of the format ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10'];

These can either be imported and used directly or in conjunction with the makeNumeralTranslator helper function below.

makeNumeralTranslator(system)

makeNumeralTranslator is a small helper that returns a function that translates any 'Western' Arabic numerals in the input string into the specified numeral system.

It accepts one argument system which is an array of numeral system symbols such as one of the ones above, and returns a translator function. If the argument is omitted or an invalid numeral system is supplied then the translator returns input strings unchanged. Note that currently only the first 10 symbols from the array are used.

For an example see Usage, below.

Installation

npm install @bbc/psammead-locales --save

Usage

Moment locales

import moment from 'moment';
import '@bbc/psammead-locales/moment/ig';

moment.locale('ig');

Numerals

import { Bengali, makeNumeralTranslator } from '@bbc/psammead-locales/numerals';

const translateNumerals = makeNumeralTranslator(Bengali);
const result = translateNumerals(someInput); // returns someInput with numbers translated to Bengali

Contributing

Psammead is completely open source. We are grateful for any contributions, whether they be new components, bug fixes or general improvements. Please see our primary contributing guide which can be found at the root of the Psammead respository.

Code of Conduct

We welcome feedback and help on this work. By participating in this project, you agree to abide by the code of conduct. Please take a moment to read it.

License

Psammead is Apache 2.0 licensed.

版本与发布记录

@bbc/psammead-locales 共发布 70 个版本,首次发布于 2019/06/19;过去 12 个月发布了 0 个版本。

版本发布日期距今
5.0.7latest2021/05/275 年前
5.0.62021/03/105 年前
5.0.52021/03/025 年前
5.0.42021/02/225 年前
5.0.32021/02/045 年前
5.0.22021/01/225 年前

关于 @bbc/psammead-locales 的常见问题

@bbc/psammead-locales 是什么?

A collection of locale configs, used in BBC World Service sites

如何安装 @bbc/psammead-locales?

在项目目录运行 npm install @bbc/psammead-locales,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(>=16.9.0)、@emotion/styled(^11.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@bbc/psammead-locales 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/bbc__psammead-locales 是否存在。

@bbc/psammead-locales 可以商用吗?

@bbc/psammead-locales 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@bbc/psammead-locales 的下载量有多少?

根据 npm 官方下载统计,@bbc/psammead-locales 在 2026/10/08 – 2026/11/06 这 30 天内被下载 6,578 次,日均约 219 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@bbc/psammead-locales 还在维护吗?

最新版本 5.0.7 发布于 2021/05/27(5 年前);至今共发布 70 个版本,其中过去 12 个月发布了 0 个;首次发布于 2019/06/19。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。