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

es-resx-to-js

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

es-resx-to-js

Helper module for transforming RESX loc files to JS file.

  • 1.0.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
increased by100%
Maintainers
1
Weekly downloads
 
Created
Source

Resx to JS

This is a small helper module which is transforming the localization files from RESX files into JS files.

JS files are being created by template.

package.json

#!json

"devDependencies": {
  "es-resx-to-js": "^1.0.0"
}

How to setup the GULP task

#!javascript

// Import the RESX to JS module
var resxtojs = require('es-resx-to-js');

gulp.task('TAKS_NAME', function() {
  // Module Build Function
  resxtojs.build(
    {
      // Define all mappings between RESX files and JS files
      // An array of mapping objects
      mapping: [
        {
          // Relative/Absolute path to RESX files
          // RESX files for additional languages are being automatically resolved:
          // - Based on the langs param
          // - RESX files have to follow the expected filename convention, see the section Expected RESX file format
          resx: '[...]/ExampleModule.resx',
          // Relative/Absolute path to JS file
          // JS files for additional languages are being automatically resolved.
          // - Based on the langs param
          js: '[...]/example-module.js',
          // Resource base name
          // Used as the localization root object
          resName: 'ExampleModule'
        }
      ],
      // Relative/Absolute path to the JS file template
      // This file content is being used for the JS file creating 
      // See the JS File Template Section
      template: '[...]/template.txt',
      // List of all "non-default" languages
      // OPTIONAL: If there are no other languages than just delete this param
      langs: ['es']
    },
    // Callback function which contains the log messages from the module
    function(log) {
      console.log(log);
    }
  );
});

Expected RESX file format

RESX files containing additional languages should use this name convention:

  • ExampleModule.resx - Default Language RESX file
  • EmxapleModule.es.resx - Spanish RESX file

JS File Template

#!javascript

// Root namespace
var Evoke = Evoke || {};

// Localization namespace
Evoke.App.Localization = Evoke.App.Localization || {};

/*
 * Auto-generated localization file
 * Source file: {filename}
 * Lang: {lang}
*/

// Name of the localization resource
var resName = '{resname}';

// Declare all localization strings as object paramers
Evoke.App.Localization[resName] = {
  {keyValuePairs}
};


  • {filename} - This tag is being replaced with source RESX filename
  • {lang} - This tag is being replaced with language code of given RESX file. (Default language code is set to "default")
  • {resname} - This tag is being replaced with Resource Base Name
  • {keyValuePairs} - This tag is being replaced with generated Key Value pairs of localization entries

FAQs

Package last updated on 08 Aug 2016

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