GithubHelp home page GithubHelp logo

resx2tsjs's Introduction

resx2tsjs

Source code for the resx2tsjs node module, originally forked from resx-to-ts-json

This node module converts resx files to TypeScript definition files and JSON files.

It supports having nested resources through underscore separated keys in the resx. For example, if you have two resources in your resx with keys "Home_help" and "Home_button", the .d.ts and .json files would look like so:

.d.ts
Home: {
    help: string;
    button: string;
}

.json
Home: {
    help: "Help string",
    button: "Button text"
}

Also you can disable nested resources by pass paramater isAllowNest to true,default is false. The script has two exported functions:

function executeResxToTs(typeScriptResourcesNamespace: string, virtualResxFolder: string, virtualTypeScriptFolder: string, isAllowNest:boolean = false): void;
function executeResxToJson(virtualResxFolder: string, virtualJsonFolder: string, isAllowNest:boolean = false,fileNameLanguage?: string): void;

executeResxToTs converts all resx files in the virtualResxFolder to TypeScript definition files (.d.ts) with the namespace defined as typeScriptResourcesNamespace and outputs these files to virtualTypeScriptFolder
executeResxToJson converts all resx files in the virtualResxFolder to JSON files (.json) which can be loaded in the application and outputs them to virtualJsonFolder. Optionally, you can specify a fileNameLanguage string to append to the file name, so if "en" was specified, the filename would be filename.en.json.

Usage

To use this node module add a reference to your project package.json dependencies.

{
    "dependencies": {
        "resx-to-ts-json": "1.0.14"
    }
}

To use the module in for instance a gulp task:

var resxConverter = require('resx-to-ts-json');
resxConverter.executeResxToTs('exampleApp.resources', '/Resources', '/App/Resources', true);
resxConverter.executeResxToJson('/Resources', '/App/Resources/Json', true);

where the parameters stand for:

'exampleApp.resources' -> TypeScript module name / namespace for the resource models.
'/Resources' -> Relative folder to scan for .resx files.
'/App/Resources' -> Output directory for TypeScript files
'/App/Resources/Json -> Output directory for JSON files

UPDATES:

2017-07-14 add paramater for disable nested resoures.(v 1.0.0)

resx2tsjs's People

Contributors

claytonwang avatar

Stargazers

Fabian Gander avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.