@exodus/pofile

中文文档
3.4.0发布于 2026/09/09MITCommonJS零依赖近 30 天下载 1.4万

Simple PO file parser

原始使用文档
文档目录3 节
  1. Install
  2. Usage
  3. Computed IDs for messages

@exodus/pofile

Simple PO file parser

Install

pnpm add @exodus/pofile

Usage

const PO = require('@exodus/po')

const poContent = `
#: ./src/index.js
msgid "Test message"
msgstr "Mensaje de prueba"

# Other comment
#: ./src/ui.js
msgid "Test dynamic message {assetName}"
msgstr "Mensaje dinámico de prueba {assetName}"
`

const instance = PO.parse(poContent)

console.log(instance.entries)
// [
//   {
//     comments: [],
//     references: ['./src/index.js'],
//     msgid: 'Test message',
//     msgstr: 'Mensaje de prueba'
//   },
//   {
//     comments: ['Other comment'],
//     references: ['./src/ui.js'],
//     msgid: 'Test dynamic message {assetName}',
//     msgstr: 'Mensaje dinámico de prueba {assetName}'
//   }
// ]

instance.addEntry({
  id: 'Welcome to Exodus',
  value: 'Bienvenido a Exodus',
  comments: ['Some comment'],
})

console.log(instance.toString())
// #: ./src/index.js
// msgid "Test message"
// msgstr "Mensaje de prueba"

// # Other comment
// #: ./src/ui.js
// msgid "Test dynamic message {assetName}"
// msgstr "Mensaje dinámico de prueba {assetName}"
//
// #: Some comment
// msgid "Welcome to Exodus"
// msgstr "Bienvenido a Exodus"

Computed IDs for messages

By default a POFile will not use the msgid property as-is to identify a message, instead it will compute an internal id with normalized variables. This allows this lib to re-use a translation when just the variable name is different.

# msgid
Click on\n{name} button

# computed id
Click on\n{} button

You can disable this behaviour by specifying computedIdsEnabled as false when reating a POFile.

new POFile({ computedIdsEnabled: false })

版本与发布记录

@exodus/pofile 共发布 21 个版本,首次发布于 2022/10/15;过去 12 个月发布了 3 个版本。

版本发布日期距今
3.4.0latest2026/09/092 个月前
3.3.32026/08/063 个月前
3.3.22026/06/065 个月前
3.3.12025/03/131.7 年前
3.3.02025/02/181.7 年前
3.2.32025/02/101.8 年前

关于 @exodus/pofile 的常见问题

@exodus/pofile 是什么?

Simple PO file parser

如何安装 @exodus/pofile?

在项目目录运行 npm install @exodus/pofile,或使用 pnpm add / yarn add / bun add。

@exodus/pofile 支持 TypeScript 吗?

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

@exodus/pofile 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@exodus/pofile 可以商用吗?

@exodus/pofile 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@exodus/pofile 的下载量有多少?

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

@exodus/pofile 还在维护吗?

最新版本 3.4.0 发布于 2026/09/09(2 个月前);至今共发布 21 个版本,其中过去 12 个月发布了 3 个;首次发布于 2022/10/15。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。