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 - npm Package Compare versions

Comparing version 0.0.0 to 0.0.1

2

package.json
{
"name": "i18n-lookup",
"version": "0.0.0",
"version": "0.0.1",
"description": "Utility node module for doing lookups from translation documents",

@@ -5,0 +5,0 @@ "main": "index.js",

# 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](https://www.npmjs.com/package/i18next).
```javascript
/**
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.
```javascript
/**
Locale: {
greeting: 'Hello {{name}}'
}
**/
var t = require('i18next').t,
Mustache = require('mustachejs');
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"
```
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