New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-i18n-gettext

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-i18n-gettext

React i18n module, based on Jed and gettext, support locale po builder

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

React-i18n-gettext

Install

npm install react-i18n-gettext

i18n - Localization

  • We use Jed and gettext to support localization for our page and components.
  • For page, i18n will fetch locale data by async getInitialProps.
  • For component, i18n will get locale data by context from I18nProvider inside.

locale builder

Scan files and generate PO files and push to Smartling, then pull the translations content. Fianlly convert PO to JSON.

node builder/build.js
# OR
make locale_build

i18n API:

gettext(txt)
pgettext(context, txt)
ngettext(txt, pluralTxt, count)
npgettext(context, txt, pluralTxt, count)

For page:

import { localizePage, type I18nType } from 'react-i18n-gettext';

class Page extends React.Component {
    props: {
        i18n: I18nType,

        ...
    }

    render() {
        const { gettext } = this.props.i18n;
        return <div>{gettext('hello')}</div>;
    }

    ...
}

export default localizePage(Page);

For component:

import { translate, type I18nType } from 'react-i18n-gettext';

class Comp extends React.Component {
    props: {
        i18n: I18nType,

        ...
    }

    render() {
        const { gettext } = this.props.i18n;
        return <div>{gettext('hello')}</div>;
    }

    ...
}

export default translate(Comp);

// _Comp is for jest test, we won't test translated component directly
export {
    Comp as _Comp,

    ...
};

Keywords

FAQs

Package last updated on 06 Jun 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc