New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

i18next-translation-parser

Package Overview
Dependencies
Maintainers
2
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

i18next-translation-parser

parses i18next translations to AST

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
12K
increased by2.55%
Maintainers
2
Weekly downloads
 
Created
Source

Introduction

Travis Coveralls npm version David

This is a module to parse an i18next translation string into an AST and back to a string.

Getting started

Source can be loaded via npm or downloaded from this repo.

# npm package
$ npm install i18next-translation-parser

Sample

import { parse, stringify } from 'i18next-translation-parser';

const AST = parse('<div>test</div>');
// will return
/*
[
  {
    "type": "tag",
    "name": "div",
    "voidElement": false,
    "attrs": {},
    "children": [
      {
        "type": "text",
        "content": "test"
      }
    ]
  }
]
*/
stringify(AST); // -> '<div>test</div>'

parse('test {{val}} text {{- encoded}} with {{val, format}} some $t{nesting} help');
// will return
/*
[
  {
    "type": "text",
    "content": "test "
  },
  {
    "type": "interpolation",
    "raw": "{{val}}",
    "prefix": "{{",
    "suffix": "}}",
    "content": "val",
    "variable": "val"
  },
  {
    "type": "text",
    "content": " text "
  },
  {
    "type": "interpolation_unescaped",
    "raw": "{{- encoded}}",
    "prefix": "{{-",
    "suffix": "}}",
    "content": " encoded",
    "variable": "encoded"
  },
  {
    "type": "text",
    "content": " with "
  },
  {
    "type": "interpolation",
    "raw": "{{val, format}}",
    "prefix": "{{",
    "suffix": "}}",
    "content": "val, format",
    "variable": "val, format"
  },
  {
    "type": "text",
    "content": " some "
  },
  {
    "type": "nesting",
    "raw": "$t{nesting}",
    "prefix": "$t{",
    "suffix": "}",
    "content": "nesting",
    "variable": "nesting"
  },
  {
    "type": "text",
    "content": " help"
  }
]
*/

Keywords

FAQs

Package last updated on 24 Oct 2019

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