Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including dotup-ts-internationalization with all npm packages installed. Try it out:

var dotupTsInternationalization = require("dotup-ts-internationalization")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

dotup-ts-internationalization v1.0.7

Library for typed translation and internationalization

Build Status


Library for typed translation and internationalization


enum TextKeys {
  'Hello' = 'Hello', 'WithTextLink' = 'WithTextLink', 'Slang' = 'Slang',
  PluralizedWithGender = 'PluralizedWithGender',
  DirectText = 'DirectText',
  Pluralized = 'Pluralized',
  TextArray = 'TextArray',
  PlaceHolderText = 'PlaceHolderText',
  Gendered = 'Gendered',
  NamedPlaceHolderText = 'NamedPlaceHolderText'

const translations: Translations<TextKeys> = {
  'de-DE': {
    PlaceHolderText: 'Text with {0}',
    NamedPlaceHolderText: 'Text two with {MyVariable}',
    DirectText: 'DirectText',
    TextArray: ['TextArray1', 'TextArray2'],
    WithTextLink: ['$(DirectText) with $(Slang)'],
    Gendered: {
      male: 'is male',
      female: 'is female'
    Pluralized: {
      plural: {
        zero: 'zero',
        one: 'one',
        few: 'few',
        many: 'many',
        other: 'other',
        two: 'two'
    PluralizedWithGender: {

      plural: {
        few: {
          female: [''],
          male: 'he has #'
        one: {
          female: ['plural-one-female # $(DirectText)'],
          male: 'plural-one-male $(DirectText)'
        other: 'plural-other $(DirectText)',
        many: ''
      ordinal: {
        one: ['erstes $(Hello)'],
        other: 'zweites $(Hello)'
    Hello: ['Hallo', 'Hi', 'Servus'],
    Slang: ['nasen', 'eumel', 'vögel']

// Initialize required languages
InitializeIntl(LanguageEnum.deDE, LanguageEnum.enGB);

// Initialize text library with text
const tlib = new TextLibrary(translations);
// Get a translator for a specific language
const t = tlib.getTranslator(LanguageEnum.deDE);

// Translate
const result = t.format({
  key: TextKeys.PluralizedWithGender,
  gender: GenderGroups.male,
  plural: {
    group: PluralGroups.plural,
    value: 1
console.log(`format 1: ${result}`);



RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free