npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

resx-to-ts-json

v1.0.14

Published

Converts resx files to TypeScript definitions and json files

Downloads

146

Readme

resx-to-ts-json

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

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"
}

The script has two exported functions:

function executeResxToTs(typeScriptResourcesNamespace: string, virtualResxFolder: string, virtualTypeScriptFolder: string): void;
function executeResxToJson(virtualResxFolder: string, virtualJsonFolder: string, 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');
resxConverter.executeResxToJson('/Resources', '/App/Resources/Json');

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-02-13 Remove unnecessary escaping of single quotes in string values. (v 1.0.14)

2016-09-20 Switched to creating a typescript definition file (.d.ts), json file (.json), and added support for nested resources using '_' between key names. (v 1.0.13)

2016-08-19 Refactored code and added support for multi line resources. (v 1.0.12)

Voilá, the TypeScript models for your resx files are added to your project and ready to use in typescript development/mvc bundling.