🚀 DAY 5 OF LAUNCH WEEK: Introducing Socket Firewall Enterprise.Learn more →
Socket
Book a DemoInstallSign in
Socket

i18n-translator-for-json-templates

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

i18n-translator-for-json-templates

An i18n like translator for json templates

latest
Source
npmnpm
Version
1.0.5
Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

i18nTranslatorForJsonTemplates

An i18n like translator for json templates(typescript/javascript).

this package has been developed for cases which you want to use a feature like i18n but on json templates which will be fetched from server like json schema form generators like below example(note:you can use {{}} or any other tags like t() for templateing):

//json template
{
      "platformType": "{{specification.platformType}}",
      "ownershipMode": "COBO",
      "version": 1,
      "description": "{{specification.description}}",
      "label": "{{specification.label}}"
}
//json lang
 {"specification": {
        "platformType": "Android",
        "description": "Command Schema For 'Company Owned/Business Only'",
        "label": "COBO3"
      }
 }
import i18nTranslatorForJsonTemplates from "i18n-translator-for-json-templates";
const result = i18nTranslatorForJsonTemplates(lang, template);
console.log(JSON.stringify(result));
/*output
 {                                                                       
   "platformType": "Android",                                            
   "ownershipMode": "COBO",                                              
   "version": 1,                                                         
   "description": "Command Schema For 'Company Owned/Business Only'",    
   "label": "COBO3"                                                      
 }                                                                       
*/

i18nTranslatorForJsonTemplates takes 4 args, which the last two of the are optionals as below:

i18nTranslatorForJsonTemplates = (
  language_json: any,
  template_json: any,
  start_of_pattern = '{{',
  end_of_pattern = '}}',
) => string

Keywords

i18n translator for json templates

FAQs

Package last updated on 30 Jun 2020

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