2.0.0 • Published 11 months ago

intl-utils v2.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

intl-utils

This is an utility for internationalization of applications.

An example with NextJS will be as follows:

import withRouter, { WithRouterProps } from 'next/dist/client/with-router';
import buildTranslateFunction from 'intl-utils';

import translations from './translations';

function HomePage(props: WithRouterProps) {
  const t = buildTranslateFunction(translations, props.router.locale);

  return <p>{t('Hello World')}</p>
}

export default withRouter(HomePage);

Where translations.js is as follows:

/* spellchecker: disable */
module.exports = {
  "es": {
    "Hello World": "Hola mundo"
  },
  "fr": {
    "Hello World": "Bonjour le monde"
  },
  "it": {
    "Hello World": "Ciao mondo"
  },
  "pt": {
    "Hello World": "Olá, mundo"
  }
}

The structure of the file is:

module.exports = {
  LOCALE: {
    KEY: TRANSLATED_KEY
  }
}

Where TRANSLATED_KEY is the translation of KEY on LOCALE

Please note that intl-utils-aws-translate can help you to automatically generate the translation files using AWS Translate.

Release Process

  • Commit your changes
  • Test your changes npm test
  • Adjust the version, e.g.: npm version patch
  • Build npm run build
  • Publish npm publish
  • Push the changes e.g. git push --tags && git push
  • Create the release in Github
1.0.6

11 months ago

1.0.5

11 months ago

1.0.4

11 months ago

2.0.0

11 months ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago

8.0.11

1 year ago