Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@cerner/terra-aggregate-translations

Package Overview
Dependencies
Maintainers
10
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cerner/terra-aggregate-translations - npm Package Compare versions

Comparing version 2.4.0 to 3.0.0

5

CHANGELOG.md

@@ -5,2 +5,7 @@ # Changelog

## 3.0.0 - (May 12, 2022)
* Breaking
* Removed intl v3 and v4 support.
## 2.4.0 - (February 11, 2022)

@@ -7,0 +12,0 @@

27

lib/aggregate-translations.js

@@ -13,8 +13,4 @@ "use strict";

var glob = require('glob'); // eslint-disable-next-line import/no-unresolved
var glob = require('glob');
var _require = require('react-intl'),
intlShape = _require.intlShape;
var supportedLocales = require('./config/i18nSupportedLocales');

@@ -26,4 +22,2 @@

var writeI18nLoaders = require('./write-i18n-loaders');
var defaultSearchPatterns = require('./config/defaultSearchPatterns');

@@ -91,4 +85,3 @@

outputDir = _defaults.outputDir,
excludes = _defaults.excludes,
format = _defaults.format;
excludes = _defaults.excludes;

@@ -112,17 +105,5 @@ var searchPaths = [].concat((0, _toConsumableArray2.default)(defaultSearchPatterns), (0, _toConsumableArray2.default)(directories));

var outputDirectory = path.resolve(baseDir, outputDir);
fileSystem.mkdirpSync(outputDirectory);
/**
* Detecting react-intl version used. `react-intl` v3 and greater does not export the intlShape.
* In order to use these versions of `react-intl` consumers should utilize terra-application v2, which provides the i18n loaders.
*/
fileSystem.mkdirpSync(outputDirectory); // Write aggregated translation messages to a file for each locale
var isReactIntlv5 = !intlShape; // Write aggregated translation messages to a file for each locale
writeAggregatedTranslations(aggregatedMessages, locales, fileSystem, outputDirectory, isReactIntlv5);
if (!isReactIntlv5) {
// Write intl and translations loaders for the specified locales
writeI18nLoaders(locales, fileSystem, outputDirectory, format);
}
writeAggregatedTranslations(aggregatedMessages, locales, fileSystem, outputDirectory);
return locales;

@@ -129,0 +110,0 @@ };

@@ -22,21 +22,11 @@ "use strict";

var translationFile = function translationFile(locale, baseLocale, messages) {
return "'use strict';\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.messages = exports.locale = exports.areTranslationsLoaded = undefined;\n\nvar _reactIntl = require('react-intl');\n\nvar _".concat(baseLocale, " = require('react-intl/locale-data/").concat(baseLocale, "');\n\nvar _").concat(baseLocale, "2 = _interopRequireDefault(_").concat(baseLocale, ");\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\n(0, _reactIntl.addLocaleData)(_").concat(baseLocale, "2.default);\n\nvar messages = ").concat(JSON.stringify(messages, null, 2), ";\nvar areTranslationsLoaded = true;\nvar locale = '").concat(locale, "';\nexports.areTranslationsLoaded = areTranslationsLoaded;\nexports.locale = locale;\nexports.messages = messages;\n");
};
var v5TranslationFile = function v5TranslationFile(messages) {
var translationFile = function translationFile(messages) {
return "'use strict';\n\n Object.defineProperty(exports, \"__esModule\", {\n value: true\n });\n exports.default = void 0;\n\n var _default = ".concat(JSON.stringify(messages, null, 2), ";\n exports.default = _default;\n");
};
var generateTranslationFile = function generateTranslationFile(locale, messages, isReactIntlV5) {
var generateTranslationFile = function generateTranslationFile(messages) {
var sortedMessages = sortMessages(messages);
var baseLocale = locale.split('-')[0];
if (isReactIntlV5) {
return v5TranslationFile(sortedMessages);
}
return translationFile(locale, baseLocale, sortedMessages);
return translationFile(sortedMessages);
};
module.exports = generateTranslationFile;

@@ -21,3 +21,3 @@ "use strict";

var writeAggregatedTranslations = function writeAggregatedTranslations(aggregatedMessages, locales, fileSystem, outputDir, isReactIntlV5) {
var writeAggregatedTranslations = function writeAggregatedTranslations(aggregatedMessages, locales, fileSystem, outputDir) {
// Create a file of aggregated translation messages for each locale

@@ -50,3 +50,3 @@ locales.forEach(function (locale) {

fileSystem.writeFileSync(translationFilePath, generateTranslationFile(locale, mergedMessages, isReactIntlV5));
fileSystem.writeFileSync(translationFilePath, generateTranslationFile(mergedMessages));
} else {

@@ -53,0 +53,0 @@ throw new Error(chalk.red("Translations aggregated for ".concat(locale, " locale, but messages were not loaded correctly. Please check that your translated modules were installed correctly.")));

{
"name": "@cerner/terra-aggregate-translations",
"version": "2.4.0",
"version": "3.0.0",
"description": "The terra-aggregate-translations pre-build tool assists with creating the translation, intl loader and translation loader files that are configured for the specified locales. This tool is offered as a CLI script and as a setup function.",

@@ -57,5 +57,5 @@ "publishConfig": {

"intl": "^1.2.5",
"react-intl": "^2.8.0 || ^5.0.0"
"react-intl": "^5.8.2"
},
"gitHead": "a9478fada603a7fc70962319d7a223930d67cf9a"
"gitHead": "61b9c61732414b3cccfa7b62a36d604c95c3b4f8"
}
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