@lingui/cli 4.0.0-next.0 → 4.0.0-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -16,8 +16,8 @@ const extractor = {
16
16
  match(filename) {
17
17
  return babelRe.test(filename);
18
18
  },
19
- async extract(filename, code, onMessageExtracted, linguiConfig, ctx) {
20
- const parserOptions = linguiConfig.extractorParserOptions;
19
+ async extract(filename, code, onMessageExtracted, ctx) {
20
+ const parserOptions = ctx.linguiConfig.extractorParserOptions;
21
21
  const parserPlugins = [
22
22
  // https://babeljs.io/docs/en/babel-parser#latest-ecmascript-features
23
23
  ["decorators", {
@@ -58,7 +58,7 @@ const extractor = {
58
58
  resolvePath: source => require.resolve(source),
59
59
  lingui: {
60
60
  extract: true,
61
- linguiConfig
61
+ linguiConfig: ctx.linguiConfig
62
62
  }
63
63
  }], [_babelPluginExtractMessages.default, {
64
64
  onMessageExtracted: msg => {
@@ -22,7 +22,9 @@ async function extract(filename, onMessageExtracted, linguiConfig, options) {
22
22
  if (!ext.match(filename)) continue;
23
23
  try {
24
24
  const file = await _promises.default.readFile(filename);
25
- await ext.extract(filename, file.toString(), onMessageExtracted, linguiConfig);
25
+ await ext.extract(filename, file.toString(), onMessageExtracted, {
26
+ linguiConfig
27
+ });
26
28
  return true;
27
29
  } catch (e) {
28
30
  console.error(`Cannot process file ${filename} ${e.message}`);
@@ -8,14 +8,11 @@ var _chalk = _interopRequireDefault(require("chalk"));
8
8
  var _chokidar = _interopRequireDefault(require("chokidar"));
9
9
  var _fs = _interopRequireDefault(require("fs"));
10
10
  var _commander = require("commander");
11
- var plurals = _interopRequireWildcard(require("make-plural"));
12
11
  var _conf = require("@lingui/conf");
13
12
  var _compile = require("./api/compile");
14
13
  var _help = require("./api/help");
15
14
  var _api = require("./api");
16
15
  var _getCatalogs = require("./api/catalog/getCatalogs");
17
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
18
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
19
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20
17
  function command(config, options) {
21
18
  const catalogs = (0, _api.getCatalogs)(config);
@@ -25,13 +22,6 @@ function command(config, options) {
25
22
  let mergedCatalogs = {};
26
23
  console.log("Compiling message catalogs…");
27
24
  for (const locale of config.locales) {
28
- const [language] = locale.split(/[_-]/);
29
- // todo: this validation should be in @lingui/conf
30
- // todo: validate locales according bcp47, instead of plurals
31
- if (locale !== config.pseudoLocale && !plurals[language]) {
32
- console.error(_chalk.default.red(`Error: Invalid locale ${_chalk.default.bold(locale)} (missing plural rules)!`));
33
- console.error();
34
- }
35
25
  for (const catalog of catalogs) {
36
26
  const missingMessages = [];
37
27
  const messages = catalog.getTranslations(locale, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lingui/cli",
3
- "version": "4.0.0-next.0",
3
+ "version": "4.0.0-next.1",
4
4
  "description": "CLI for working wit message catalogs",
5
5
  "keywords": [
6
6
  "cli",
@@ -51,12 +51,11 @@
51
51
  "@babel/plugin-syntax-jsx": "^7.18.6",
52
52
  "@babel/runtime": "^7.20.13",
53
53
  "@babel/types": "^7.20.7",
54
- "@lingui/babel-plugin-extract-messages": "^4.0.0-next.0",
55
- "@lingui/conf": "^4.0.0-next.0",
56
- "@lingui/core": "^4.0.0-next.0",
54
+ "@lingui/babel-plugin-extract-messages": "^4.0.0-next.1",
55
+ "@lingui/conf": "^4.0.0-next.1",
56
+ "@lingui/core": "^4.0.0-next.1",
57
57
  "@messageformat/parser": "^5.0.0",
58
58
  "babel-plugin-macros": "^3.0.1",
59
- "bcp-47": "^1.0.7",
60
59
  "chalk": "^4.1.0",
61
60
  "chokidar": "3.5.1",
62
61
  "cli-table": "0.3.6",
@@ -65,7 +64,6 @@
65
64
  "date-fns": "^2.16.1",
66
65
  "glob": "^7.1.4",
67
66
  "inquirer": "^7.3.3",
68
- "make-plural": "^6.2.2",
69
67
  "micromatch": "4.0.2",
70
68
  "mkdirp": "^1.0.4",
71
69
  "node-gettext": "^3.0.0",
@@ -88,5 +86,5 @@
88
86
  "mock-fs": "^5.2.0",
89
87
  "mockdate": "^3.0.2"
90
88
  },
91
- "gitHead": "637f5cf6beda9d4ebce4e15cd9fdaa23e404b660"
89
+ "gitHead": "27ee8e213ff6d0c7a0cd2b21c573d7f6da43fd85"
92
90
  }
@@ -1,36 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.isValid = isValid;
7
- exports.parse = parse;
8
- var plurals = _interopRequireWildcard(require("make-plural/plurals"));
9
- var _bcp = _interopRequireDefault(require("bcp-47"));
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
12
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
13
- /**
14
- * Check that locale is valid according to BCP47 and we have plurals for it
15
- * @param locale: string - Locale in BCP47 format
16
- * @return {boolean}
17
- */
18
- function isValid(locale) {
19
- const localeData = parse(locale);
20
- return localeData !== null && localeData !== undefined && localeData.language in plurals;
21
- }
22
-
23
- /**
24
- * Parse locale in BCP47 format and
25
- * @param locale - Locale in BCP47 format
26
- * @return {LocaleInfo}
27
- */
28
- function parse(locale) {
29
- if (typeof locale !== "string") return null;
30
- const schema = _bcp.default.parse(locale.replace("_", "-"));
31
- if (!schema.language) return null;
32
- return {
33
- locale: _bcp.default.stringify(schema),
34
- language: schema.language
35
- };
36
- }