@exodus/pofile

3.3.1 • Public • Published

@exodus/pofile

Simple PO file parser

Install

yarn 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 })

Readme

Keywords

none

Package Sidebar

Install

npm i @exodus/pofile

Weekly Downloads

3,228

Version

3.3.1

License

MIT

Unpacked Size

19.2 kB

Total Files

12

Last publish

Collaborators

  • juraex
  • kevva
  • doguhan
  • janwe
  • yevhenii_molodyk
  • javiexodus
  • ismamz
  • exojo
  • feri42
  • jprichardson
  • farisissa
  • ryanzim
  • headfire
  • gutenye
  • mosesbot
  • roccomuso
  • dcastagnoli
  • sonaye
  • ves
  • tenaciousmv
  • asyakost
  • bulgakovk
  • chalker
  • andrejb
  • jaydp17
  • olistic
  • joepie91
  • merlz
  • vbonini
  • mol0d
  • devopsrobot
  • jenish-sojitra
  • markoexodus
  • nachoalvarez
  • giovannirco
  • filipexodus
  • cryptosgr
  • andrescarreon
  • diegomura
  • lanre-mark
  • sunilagrawal
  • guillecura
  • mariosvlad
  • federico-po
  • akinncar
  • fboucquez
  • lanahizzle
  • kwwood
  • umito
  • joshuabot
  • iaacek
  • meniem
  • skapala
  • awilson-rs
  • ggabarrin-rs
  • ralph.ba
  • danh.t.vo
  • voltagebots
  • ryansquared-npm
  • alexandrbbm
  • sergii_bo
  • florianmathieu
  • angelloz
  • exodus-justin.za
  • alex.alexandrius
  • rec
  • rg911
  • jamiemaw
  • james-gre
  • shehryar6
  • geoffreyrousset
  • clarkexo
  • tunguyennnnn
  • jschopen
  • cawfree
  • marcos.kichel
  • andrewtoth-exodus
  • cdotta-exodus
  • exorich
  • mmehta-10
  • kryptkeep
  • 633kh4ck
  • mbaraniak-exodus
  • jeehahn
  • hasakura
  • awesomeniko
  • davidexodus
  • r4vn
  • nantoaqui
  • exoleo
  • ale-exo
  • frankliexodus
  • bekatd
  • ronaldcrb
  • muratso
  • yalomist
  • joshua-rogers-exodus
  • jdmdreamer
  • vikas027
  • angel_exodus
  • sripwoud
  • coreycollins
  • xogdg
  • chrisrichexo
  • harshjv
  • josuexo
  • garana-exodus