@vocab/react 1.1.7 → 1.1.9

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 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
@@ -1,5 +1,5 @@
1
1
  import type { TranslationFile, LanguageName, ParsedFormatFnByKey, ParsedFormatFn } from '@vocab/core';
2
- import { type ReactNode } from 'react';
2
+ import React, { type ReactNode } from 'react';
3
3
  type Locale = string;
4
4
  interface TranslationsValue {
5
5
  language: LanguageName;
@@ -8,7 +8,7 @@ interface TranslationsValue {
8
8
  interface VocabProviderProps extends TranslationsValue {
9
9
  children: ReactNode;
10
10
  }
11
- export declare const VocabProvider: ({ children, language, locale, }: VocabProviderProps) => JSX.Element;
11
+ export declare const VocabProvider: ({ children, language, locale, }: VocabProviderProps) => React.JSX.Element;
12
12
  export declare const useLanguage: () => TranslationsValue;
13
13
  type FormatXMLElementReactNodeFn = (parts: ReactNode[]) => ReactNode;
14
14
  type MapToReactNodeFunction<Params extends Record<string, any>> = {
@@ -1 +1,2 @@
1
1
  export * from "./declarations/src/index";
2
+ //# sourceMappingURL=vocab-react.cjs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vocab-react.cjs.d.ts","sourceRoot":"","sources":["./declarations/src/index.d.ts"],"names":[],"mappings":"AAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vocab/react",
3
- "version": "1.1.7",
3
+ "version": "1.1.9",
4
4
  "main": "dist/vocab-react.cjs.js",
5
5
  "module": "dist/vocab-react.esm.js",
6
6
  "author": "SEEK",
@@ -12,7 +12,7 @@
12
12
  "dist"
13
13
  ],
14
14
  "dependencies": {
15
- "@vocab/core": "^1.4.0",
15
+ "@vocab/core": "^1.6.0",
16
16
  "intl-messageformat": "^10.0.0"
17
17
  },
18
18
  "devDependencies": {