@vocab/webpack 1.2.3 → 1.2.5
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.
- package/README.md +35 -3
- package/chunk-name/dist/vocab-webpack-chunk-name.cjs.d.ts +1 -0
- package/chunk-name/dist/vocab-webpack-chunk-name.cjs.d.ts.map +1 -0
- package/dist/declarations/src/index.d.ts +1 -1
- package/dist/declarations/src/loader.d.ts +1 -1
- package/dist/vocab-webpack.cjs.d.ts +1 -0
- package/dist/vocab-webpack.cjs.d.ts.map +1 -0
- package/loader/dist/vocab-webpack-loader.cjs.d.ts +1 -0
- package/loader/dist/vocab-webpack-loader.cjs.d.ts.map +1 -0
- package/loader/dist/vocab-webpack-loader.cjs.dev.js +1 -1
- package/loader/dist/vocab-webpack-loader.cjs.prod.js +1 -1
- package/loader/dist/vocab-webpack-loader.esm.js +1 -1
- package/package.json +2 -2
- package/web/dist/vocab-webpack-web.cjs.d.ts +1 -0
- package/web/dist/vocab-webpack-web.cjs.d.ts.map +1 -0
- package/dist/declarations/src/logger.d.ts +0 -3
package/README.md
CHANGED
|
@@ -29,7 +29,7 @@ $ npm i --save @vocab/core @vocab/react
|
|
|
29
29
|
|
|
30
30
|
### Step 2: Configure Vocab
|
|
31
31
|
|
|
32
|
-
You can configure Vocab directly when calling the API or via a `vocab.config.js` file.
|
|
32
|
+
You can configure Vocab directly when calling the API or via a `vocab.config.js` or `vocab.config.cjs` file.
|
|
33
33
|
|
|
34
34
|
In this example we've configured two languages, English and French, where our initial `translation.json` files will use English.
|
|
35
35
|
|
|
@@ -184,7 +184,7 @@ t('my key with component', {
|
|
|
184
184
|
|
|
185
185
|
## Configuration
|
|
186
186
|
|
|
187
|
-
Configuration can either be passed into the Node API directly or be gathered from the nearest _vocab.config.js_ file.
|
|
187
|
+
Configuration can either be passed into the Node API directly or be gathered from the nearest _vocab.config.js_ or _vocab.config.cjs_ file.
|
|
188
188
|
|
|
189
189
|
**vocab.config.js**
|
|
190
190
|
|
|
@@ -341,7 +341,7 @@ functionality.
|
|
|
341
341
|
|
|
342
342
|
### Generating a pseudo-localized language using Vocab
|
|
343
343
|
|
|
344
|
-
Vocab can generate a pseudo-localized language via the [`generatedLanguages` config][generated languages config], either via the webpack plugin or your `vocab.config.js` file.
|
|
344
|
+
Vocab can generate a pseudo-localized language via the [`generatedLanguages` config][generated languages config], either via the webpack plugin or your `vocab.config.js` or `vocab.config.cjs` file.
|
|
345
345
|
`@vocab/pseudo-localize` exports a `generator` that can be used directly in your config.
|
|
346
346
|
|
|
347
347
|
**vocab.config.js**
|
|
@@ -506,6 +506,38 @@ Tags on keys in other languages will be ignored.
|
|
|
506
506
|
[tags]: https://support.phrase.com/hc/en-us/articles/5822598372252-Tags-Strings-
|
|
507
507
|
[configuration]: #Configuration
|
|
508
508
|
|
|
509
|
+
#### Global key
|
|
510
|
+
|
|
511
|
+
`vocab push` and `vocab pull` can support global keys mapping. When you want certain translations to use a specific/custom key in Phrase, add the `globalKey` to the structure.
|
|
512
|
+
|
|
513
|
+
```jsonc
|
|
514
|
+
// translations.json
|
|
515
|
+
{
|
|
516
|
+
"Hello": {
|
|
517
|
+
"message": "Hello",
|
|
518
|
+
"globalKey": "hello"
|
|
519
|
+
},
|
|
520
|
+
"Goodbye": {
|
|
521
|
+
"message": "Goodbye",
|
|
522
|
+
"globalKey": "app.goodbye.label"
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
```
|
|
526
|
+
|
|
527
|
+
In the above example,
|
|
528
|
+
|
|
529
|
+
- `vocab push` will push the `hello` and `app.goodbye.label` keys to Phrase.
|
|
530
|
+
- `vocab pull` will pull translations from Phrase and map them to the `hello` and `app.goodbye.label` keys.
|
|
531
|
+
|
|
532
|
+
##### Error on no translation for global key
|
|
533
|
+
|
|
534
|
+
By default, `vocab pull` will not error if a translation is missing in Phrase for a translation with a global key.
|
|
535
|
+
If you want to throw an error in this situation, pass the `--error-on-no-global-key-translation` flag:
|
|
536
|
+
|
|
537
|
+
```sh
|
|
538
|
+
vocab pull --error-on-no-global-key-translation
|
|
539
|
+
```
|
|
540
|
+
|
|
509
541
|
## Troubleshooting
|
|
510
542
|
|
|
511
543
|
### Problem: Passed locale is being ignored or using en-US instead
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vocab-webpack-chunk-name.cjs.d.ts","sourceRoot":"","sources":["../../dist/declarations/src/chunk-name.d.ts"],"names":[],"mappings":"AAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type UserConfig } from '@vocab/core';
|
|
2
2
|
import type { LoaderContext as WebpackLoaderContext } from 'webpack';
|
|
3
3
|
type LoaderContext = WebpackLoaderContext<UserConfig>;
|
|
4
4
|
export default function vocabLoader(this: LoaderContext, source: string): Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vocab-webpack.cjs.d.ts","sourceRoot":"","sources":["./declarations/src/index.d.ts"],"names":[],"mappings":"AAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vocab-webpack-loader.cjs.d.ts","sourceRoot":"","sources":["../../dist/declarations/src/loader.d.ts"],"names":[],"mappings":"AAAA"}
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var path = require('path');
|
|
6
|
+
var core = require('@vocab/core');
|
|
6
7
|
var cjsModuleLexer = require('cjs-module-lexer');
|
|
7
8
|
var esModuleLexer = require('es-module-lexer');
|
|
8
|
-
var core = require('@vocab/core');
|
|
9
9
|
var chunkName_dist_vocabWebpackChunkName = require('../../chunk-name/dist/vocab-webpack-chunk-name.cjs.dev.js');
|
|
10
10
|
var logger = require('../../dist/logger-65149486.cjs.dev.js');
|
|
11
11
|
require('chalk');
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var path = require('path');
|
|
6
|
+
var core = require('@vocab/core');
|
|
6
7
|
var cjsModuleLexer = require('cjs-module-lexer');
|
|
7
8
|
var esModuleLexer = require('es-module-lexer');
|
|
8
|
-
var core = require('@vocab/core');
|
|
9
9
|
var chunkName_dist_vocabWebpackChunkName = require('../../chunk-name/dist/vocab-webpack-chunk-name.cjs.prod.js');
|
|
10
10
|
var logger = require('../../dist/logger-f79e34a8.cjs.prod.js');
|
|
11
11
|
require('chalk');
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
|
+
import { getDevLanguageFileFromTsFile, loadTranslation } from '@vocab/core';
|
|
2
3
|
import * as cjsModuleLexer from 'cjs-module-lexer';
|
|
3
4
|
import * as esModuleLexer from 'es-module-lexer';
|
|
4
|
-
import { getDevLanguageFileFromTsFile, loadTranslation } from '@vocab/core';
|
|
5
5
|
import { getChunkName } from '../../chunk-name/dist/vocab-webpack-chunk-name.esm.js';
|
|
6
6
|
import { t as trace$1 } from '../../dist/logger-e1862ea1.esm.js';
|
|
7
7
|
import 'chalk';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vocab/webpack",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.5",
|
|
4
4
|
"main": "dist/vocab-webpack.cjs.js",
|
|
5
5
|
"module": "dist/vocab-webpack.esm.js",
|
|
6
6
|
"exports": {
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"web"
|
|
40
40
|
],
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@vocab/core": "^1.
|
|
42
|
+
"@vocab/core": "^1.6.0",
|
|
43
43
|
"chalk": "^4.1.0",
|
|
44
44
|
"cjs-module-lexer": "^1.2.2",
|
|
45
45
|
"debug": "^4.3.1",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vocab-webpack-web.cjs.d.ts","sourceRoot":"","sources":["../../dist/declarations/src/web.d.ts"],"names":[],"mappings":"AAAA"}
|