All Projects → formatjs → Babel Plugin React Intl

formatjs / Babel Plugin React Intl

Licence: other
Extracts string messages from React components that use React Intl.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Babel Plugin React Intl

Babel Plugin I18next Extract
Babel plugin that statically extracts i18next and react-i18next translation keys.
Stars: ✭ 93 (-78.37%)
Mutual labels:  babel-plugin, i18n, internationalization
labels
Bolt Labels extension - Translatable labels for Bolt
Stars: ✭ 18 (-95.81%)
Mutual labels:  i18n, internationalization
i18n
Package i18n is for app Internationalization and Localization.
Stars: ✭ 79 (-81.63%)
Mutual labels:  i18n, internationalization
Easy localization
Easy and Fast internationalizing your Flutter Apps
Stars: ✭ 407 (-5.35%)
Mutual labels:  i18n, internationalization
Fbt
A JavaScript Internationalization Framework
Stars: ✭ 3,668 (+753.02%)
Mutual labels:  i18n, internationalization
crates
🌎 A tool to generate your locale files compatible with i18n.
Stars: ✭ 52 (-87.91%)
Mutual labels:  i18n, internationalization
Spree i18n
I18n translation files for Spree Commerce.
Stars: ✭ 338 (-21.4%)
Mutual labels:  i18n, internationalization
jekyll-skeleton
Scaffolding to start with a Jekyll website
Stars: ✭ 27 (-93.72%)
Mutual labels:  i18n, internationalization
Eo Locale
🌏Internationalize js apps 👔Elegant lightweight library based on Internationalization API
Stars: ✭ 290 (-32.56%)
Mutual labels:  i18n, internationalization
React Localize Redux
Dead simple localization for your React components
Stars: ✭ 384 (-10.7%)
Mutual labels:  i18n, internationalization
Js Lingui
🌍📖 A readable, automated, and optimized (5 kb) internationalization for JavaScript
Stars: ✭ 3,249 (+655.58%)
Mutual labels:  i18n, internationalization
plate
Internationalization library for Python
Stars: ✭ 31 (-92.79%)
Mutual labels:  i18n, internationalization
rosetta
A blazing fast internationalization (i18n) library for Crystal with compile-time key lookup.
Stars: ✭ 23 (-94.65%)
Mutual labels:  i18n, internationalization
python-fluent
Python implementation of Project Fluent
Stars: ✭ 142 (-66.98%)
Mutual labels:  i18n, internationalization
cosmopolite
Typesafe internationalization for Scala
Stars: ✭ 15 (-96.51%)
Mutual labels:  i18n, internationalization
Mojito
An automation platform that enables continuous localization.
Stars: ✭ 256 (-40.47%)
Mutual labels:  i18n, internationalization
Gotext
Go (Golang) GNU gettext utilities package
Stars: ✭ 292 (-32.09%)
Mutual labels:  i18n, internationalization
wlc
Weblate command line client
Stars: ✭ 22 (-94.88%)
Mutual labels:  i18n, internationalization
GetCurrency
List all currencies available in NSLocale programmatically using swift 3
Stars: ✭ 18 (-95.81%)
Mutual labels:  i18n, internationalization
I18n4go
i18n tooling for Golang
Stars: ✭ 264 (-38.6%)
Mutual labels:  i18n, internationalization

This repo was migrated to the monorepo

babel-plugin-react-intl

travis

Extracts string messages for translation from modules that use React Intl.

Dependencies

React Intl

This Babel plugin works with React Intl v2.x

Babel

  • 3.x of this plugin works with Babel 7
  • 2.x works with Babel 6
  • 1.x works with Babel 5

Installation

$ npm install babel-plugin-react-intl

Usage

This Babel plugin only visits ES6 modules which import React Intl.

The default message descriptors for the app's default language will be extracted from: defineMessages(), <FormattedMessage>, and <FormattedHTMLMessage>; all of which are named exports of the React Intl package.

If a message descriptor has a description, it'll be removed from the source after it's extracted to save bytes since it isn't used at runtime.

Via .babelrc (Recommended)

.babelrc

{
  "plugins": [
    ["react-intl", {
        "messagesDir": "./build/messages/"
    }]
  ]
}

Options

  • messagesDir: The target location where the plugin will output a .json file corresponding to each component from which React Intl messages were extracted. If not provided, the extracted message descriptors will only be accessible via Babel's API.

  • enforceDescriptions: Whether message declarations must contain a description to provide context to translators. Defaults to: false.

  • extractSourceLocation: Whether the metadata about the location of the message in the source file should be extracted. If true, then file, start, and end fields will exist for each extracted message descriptors. Defaults to false.

  • moduleSourceName: The ES6 module source name of the React Intl package. Defaults to: "react-intl", but can be changed to another name/path to React Intl.

  • overrideIdFn: A function with the signature (id: string, defaultMessage: string, description: string|object) => string which allows you to override the ID both in the extracted javascript and messages.

  • removeDefaultMessage: Remove defaultMessage field in generated js after extraction.

  • additionalComponentNames: Additional component names to extract messages from, e.g: ['FormattedFooBarMessage']. NOTE: By default we check for the fact that FormattedMessage & FormattedHTMLMessage are imported from moduleSourceName to make sure variable alias works. This option does not do that so it's less safe.

Via Node API

The extract message descriptors are available via the metadata property on the object returned from Babel's transform() API:

require('@babel/core').transform('code', {
  plugins: ['react-intl']
}) // => { code, map, ast, metadata['react-intl'].messages };
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].