Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gettext-converter

Package Overview
Dependencies
Maintainers
2
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gettext-converter

po2js and js2po and i18next2po and po2i18next converter gettext resource utils

  • 1.3.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
58K
decreased by-7.76%
Maintainers
2
Weekly downloads
 
Created
Source

travis npm

Download

The source is available for download from GitHub. Alternatively, you can install using npm:

npm install --save gettext-converter

You can then import or require() gettext-converter as normal:

import gettext from 'gettext-converter'
// or
const gettext = require('gettext-converter')

const js = gettext.po2js(po)

Or you can direclty import or require() its functions:

import po2js from 'gettext-converter/po2js'
// or
const po2js = require('gettext-converter/cjs/po2js')

Usage


const po = `msgid ""
msgstr ""
"Project-Id-Version: gettext-converter\n"
"mime-version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
"POT-Creation-Date: 2020-04-17T10:46:16.313Z\n"
"PO-Revision-Date: 2020-04-17T10:46:16.313Z\n"

msgid "my-key"
msgstr "myvalue"`

const js = {
  charset: 'utf-8',
  headers: {
    'Project-Id-Version': 'gettext-converter',
    'mime-version': '1.0',
    'Content-Type': 'text/plain; charset=utf-8',
    'Content-Transfer-Encoding': '8bit',
    'Plural-Forms': 'nplurals=2; plural=(n != 1)',
    'POT-Creation-Date': '2020-04-17T10:46:16.313Z',
    'PO-Revision-Date': '2020-04-17T10:46:16.313Z'
  },
  translations: {
  '': {
    '': {
      msgid: '',
      msgstr: [
        'Project-Id-Version: gettext-converter\n' +
          'mime-version: 1.0\n' +
          'Content-Type: text/plain; charset=utf-8\n' +
          'Content-Transfer-Encoding: 8bit\n' +
          'Plural-Forms: nplurals=2; plural=(n != 1)\n' +
          'POT-Creation-Date: 2020-04-17T10:46:16.313Z\n' +
          'PO-Revision-Date: 2020-04-17T10:46:16.313Z\n'
      ]
    },
    'my-key': { msgid: 'my-key', msgstr: [ 'myvalue' ] }
  }
}


import po2js from 'gettext-converter/po2js'
const res = po2js(po)
// res is like js

import js2po from 'gettext-converter/js2po'
const res = js2po(js)
// res is like po


const i18nextJs = { 'my-key': 'myvalue' }

import po2i18next from 'gettext-converter/po2i18next'
const res = po2i18next(po)
// res is like i18nextJs

import i18next2po from 'gettext-converter/i18next2po'
const res = i18next2po('en', i18nextJs)
// res is like po

i18next json format v4 support

const i18nextJs = {
  'key_one': 'a value',
  'key_other': 'some values'
}

import i18next2po from 'gettext-converter/i18next2po'
const res = i18next2po('en', i18nextJs, { compatibilityJSON: 'v4' })

import po2i18next from 'gettext-converter/po2i18next'
const res = po2i18next(po, { compatibilityJSON: 'v4' })

Keywords

FAQs

Package last updated on 12 Mar 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc