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

i18n-lookup

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

i18n-lookup

Utility node module for doing lookups from translation documents

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
625
decreased by-11.85%
Maintainers
1
Weekly downloads
 
Created
Source

i18n-lookup

Utility node module for doing lookups from translation documents

Install

npm install [--save] i18n-lookup

Usage

A lookup function is returned by passing in the translation method as an argument. We normally use i18next.

/**
Locale: {
    another: {
        translation: {
            key: 'Text'
        }
    }
}
**/
var t = require('i18next').t;

var lookup = require('i18n-lookup')(t);

var translated = lookup([
    'a.translation.key',
    'another.translation.key'
]);

console.log(translated);
// This will output the first key which has a corresponding translation defined.
// => "Text"

Additionally, a template compilation method can be provided for cases where the translated key also includes template syntax.

/**
Locale: {
    greeting: 'Hello {{name}}'
}
**/
var t = require('i18next').t,
    Mustache = require('mustache');

var lookup = require('i18n-lookup')(t, Mustache.render);

var translated = lookup([
    'greeting'
], {
    name: 'John'
});

console.log(translated);
// This will output the returned lookup compiled with the provided context
// "Hello John"

FAQs

Package last updated on 11 Mar 2015

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