How to use the babel-plugin-react-intl.default function in babel-plugin-react-intl

To help you get started, we’ve selected a few babel-plugin-react-intl examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github commercetools / merchant-center-application-kit / packages / mc-scripts / extract-intl.js View on Github external
const messageKeys = Object.keys(messages);
    messageKeys.forEach(messageKey => {
      oldLocaleMappings[locale][messageKey] = messages[messageKey];
    });
  } catch (error) {
    if (error.code !== 'ENOENT') {
      process.stderr.write(
        `There was an error loading this translation file: ${translationFileName}
        \n${error}`
      );
    }
  }
});

// eslint-disable-next-line global-require
plugins.push([require('babel-plugin-react-intl').default]);

const sortMessages = localeMessages => {
  // Sort the translation JSON file so that git diffing is easier
  // Otherwise the translation messages will jump around every time we extract
  const sortedMessages = {};
  Object.keys(localeMessages)
    // transform strings to lowercase to imitate phraseapp sorting
    .sort((a, b) => a.toLowerCase().localeCompare(b.toLowerCase()))
    .forEach(key => {
      sortedMessages[key] = localeMessages[key];
    });
  return sortedMessages;
};

const extractFromFile = async fileName => {
  try {
github commercetools / ui-kit / babel.config.js View on Github external
],
      // function* () { yield 42; yield 43; }
      !isEnvTest && [
        require('@babel/plugin-transform-regenerator').default,
        {
          // Async functions are converted to generators by @babel/preset-env
          async: false,
        },
      ],
      // Adds syntax support for import()
      require('@babel/plugin-syntax-dynamic-import').default,
      isEnvTest &&
        // Transform dynamic import to require
        require('babel-plugin-transform-dynamic-import').default,
      // Extract intl messages
      require('babel-plugin-react-intl').default,
    ].filter(Boolean),
  };
};

babel-plugin-react-intl

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

BSD-3-Clause
Latest version published 4 years ago

Package Health Score

70 / 100
Full package analysis

Popular babel-plugin-react-intl functions