Skip to content

emberstack/ES.FX.JS.Gulp.Resx

Repository files navigation

gulp-resx-convert build package

A .resx file converter for gulp. Supports multiple output formats, including JSON, Typescript and C# constants class

Installation

Add this module as a development dependency:

npm install --save-dev gulp-resx-convert

Usage

This gulp plugin supports converting .resx files to multiple file types.

var resxConverter = require("gulp-resx-convert");

gulp.task("test", function () {

    gulp.src(["./Test/*.resx"]) //Pipe one or more files at a time
        .pipe(resxConverter.convert({
            //Include this for JSON
            json: {},
            //Include this for TypeScript
            typescript: {
                //Disables support for culture names in file name (ex: File.en-US.resx or File.en.resx).
                //Default: false
                culturesDisabled: false,
                //Sets the namespace to be used.
                //Default: Resx
                namespace:"Resx",
                //Enables converting to .ts files.
                //Default: false
                source: true,
                //Enables converting to .d.ts files
                //Default: false
                declaration: true
            },
			csharp: {
				//Sets the namespace to be used
				namespace: "Resx"
				//Output as properties or constants. Setting this to true will use properties
				properties: false;
				//Set this to true to create a partial class
				partial: false;
			}
        }))
        .pipe(gulp.dest("./Test/Output"));
});

Types from Resx

To specify the type to use in output instead of a string, use the Comment property in the .resx file to describe the type as in the followin example:

{"csharp":"int", "typescript":"number", "raw":true}

Setting the raw value to true means that the converter will output the value directly during assignment, without wrapping it in quotes. This should be used when the value is a number, boolean etc.

Notes

This plugin does not handle scenarios where file names contain spaces or invalid characters. Please use gulp-rename before converting the files.

Documentation

Additional documentation may be found in the Project Wiki