close
Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

README.md

typesafe-i18n Node.js

You can find a demo implementation here.

Setup

See here on more information how to set up typesafe-i18n.

manual installation

npm install typesafe-i18n

Table of Contents

Configure typesafe-i18n for an existing Node.js project

requires a node version >= 12.x

Initialize typesafe-i18n by running

npx typesafe-i18n --setup-auto

You could configure your development script to run the generator in parallel to nodemon by using npm-run-all.

{
   "scripts": {
		"dev": "npm-run-all --parallel nodemon typesafe-i18n",
		"nodemon": "nodemon src/index.ts",
		"typesafe-i18n": "typesafe-i18n"
   }
}

The generator will create some custom utils inside i18n-node.ts.

That's it. You can then start using typesafe-i18n inside your application.

import L from './i18n/i18n-node'

console.log(L.en.HI({ name: 'Node.js' })) // Hello Node.js!

exports

The file i18n-node.ts exports following function:

L

An object of type i18n you can use inside your code.
This is also the default export of that file.



For more information about typesafe-i18n, take a look at the main repository.