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

linguas-file

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

linguas-file

A library for handling LINGUAS files

  • 2.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
15
increased by1400%
Maintainers
1
Weekly downloads
 
Created
Source

linguas-file

A library to handle LINGUAS files

This library helps you handle LINGUAS files (used in gettext based i18n workflows) as specified in https://www.gnu.org/software/gettext/manual/html_node/po_002fLINGUAS.html

Installation

Install from npm:

npm i linguas-file

API

The module exposes two functions:

parse(input)

This method takes a string or a buffer representing the content of a LINGUAS file and returns an Array of strings, containing the language tokens.

Example
const fs = require('fs')
const linguasFile = require('linguas-file')

/* content of ./LINGUAS:

# languages we support
fr pt
es de

*/

fs.readFile('./LINGUAS', 'utf-8', function (err, data) {
  const tokens = linguasFile.parse(data) // => ['fr', 'pt', 'es', 'de']
})

serialize(tokens, [comment])

This method takes an Array of tokens and an optional comment and returns a valid LINGUAS file.

Example
const fs = require('fs')
const linguasFile = require('linguas-file')

const languages = ['pt', 'fr', 'es', 'de']

const file = linguasFile.serialize(
  languages, 'we are planning to support more of these'
)

fs.writeFileSync('./LINGUAS', file)

/* Content of ./LINGUAS after write:

# we are planning to support more of these
pt fr es de

*/

License

Copyright 2021 Frederik Ring - Available under the Mozilla Public License 2.0

Keywords

FAQs

Package last updated on 27 Sep 2021

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