@vocab/core 1.3.0 → 1.4.0

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
@@ -20,10 +20,11 @@ Vocab helps you ship multiple languages without compromising the reliability of
20
20
 
21
21
  ### Step 1: Install Dependencies
22
22
 
23
- Vocab is a monorepo with different packages you can install depending on your usage, the below list will get you started using the cli, React and webpack integrations.
23
+ Vocab is a monorepo with different packages you can install depending on your usage, the below list will get you started using the CLI and React integration.
24
24
 
25
25
  ```bash
26
- $ npm i --save @vocab/cli @vocab/react @vocab/webpack
26
+ $ npm i --save-dev @vocab/cli
27
+ $ npm i --save @vocab/core @vocab/react
27
28
  ```
28
29
 
29
30
  ### Step 2: Configure Vocab
@@ -116,6 +117,10 @@ Right now every language is loaded into your web application all the time, which
116
117
 
117
118
  This is done using the **VocabWebpackPlugin**. Applying this plugin to your client webpack configuration will replace all vocab files with a dynamic asynchronous chunks designed for the web.
118
119
 
120
+ ```bash
121
+ $ npm i --save-dev @vocab/webpack
122
+ ```
123
+
119
124
  **webpack.config.js**
120
125
 
121
126
  ```js
@@ -206,7 +211,7 @@ module.exports = {
206
211
  */
207
212
  generatedLanguages: [
208
213
  {
209
- name: 'generatedLangauge',
214
+ name: 'generatedLanguage',
210
215
  extends: 'en',
211
216
  generator: {
212
217
  transformElement: capitalize,
@@ -296,6 +301,10 @@ const App = () => (
296
301
 
297
302
  The `@vocab/pseudo-localize` package exports low-level functions that can be used for pseudo-localization of translation messages.
298
303
 
304
+ ```bash
305
+ $ npm i --save-dev @vocab/pseudo-localize
306
+ ```
307
+
299
308
  ```ts
300
309
  import {
301
310
  extendVowels,
@@ -441,7 +450,7 @@ $ vocab pull --branch my-branch
441
450
 
442
451
  When uploading translations, Phrase identifies keys that exist in the Phrase project, but were not
443
452
  referenced in the upload. These keys can be deleted from Phrase by providing the
444
- `---delete-unused-keys` flag to `vocab push`. E.g.
453
+ `--delete-unused-keys` flag to `vocab push`. E.g.
445
454
 
446
455
  ```sh
447
456
  $ vocab push --branch my-branch --delete-unused-keys
@@ -1,4 +1,4 @@
1
- import { LoadedTranslation, UserConfig } from './types';
1
+ import type { LoadedTranslation, UserConfig } from './types';
2
2
  export declare function generateRuntime(loadedTranslation: LoadedTranslation): Promise<void>;
3
3
  export declare function watch(config: UserConfig): () => Promise<void>;
4
4
  export declare function compile({ watch: shouldWatch }: {
@@ -1,5 +1,5 @@
1
1
  import type { TranslationsByKey, UserConfig, LoadedTranslation, LanguageTarget } from './types';
2
- import { Fallback } from './utils';
2
+ import { type Fallback } from './utils';
3
3
  export declare function getUniqueKey(key: string, namespace: string): string;
4
4
  export declare function mergeWithDevLanguageTranslation({ translation, devTranslation, }: {
5
5
  translation: TranslationsByKey;
@@ -51,6 +51,7 @@ export type TranslationFile<Language extends LanguageName, FormatFnByKey extends
51
51
  */
52
52
  load: (language: Language) => Promise<void>;
53
53
  };
54
+ export type TranslationKeys<Translations extends TranslationFile<any, ParsedFormatFnByKey>> = keyof Awaited<ReturnType<Translations['getMessages']>>;
54
55
  export interface LanguageTarget {
55
56
  name: LanguageName;
56
57
  extends?: LanguageName;
@@ -1,3 +1,3 @@
1
- import { UserConfig, LoadedTranslation, LanguageName } from '../types';
1
+ import type { UserConfig, LoadedTranslation, LanguageName } from '../types';
2
2
  export declare function findMissingKeys(loadedTranslation: LoadedTranslation, devLanguageName: LanguageName, altLanguages: Array<LanguageName>): readonly [boolean, Record<string, string[]>];
3
3
  export declare function validate(config: UserConfig): Promise<boolean>;
@@ -440,7 +440,7 @@ async function loadAllTranslations({
440
440
 
441
441
  function extractHasTags(ast) {
442
442
  return ast.some(element => {
443
- if (icuMessageformatParser.isSelectElement(element)) {
443
+ if (icuMessageformatParser.isSelectElement(element) || icuMessageformatParser.isPluralElement(element)) {
444
444
  const children = Object.values(element.options).map(o => o.value);
445
445
  return children.some(child => extractHasTags(child));
446
446
  }
@@ -440,7 +440,7 @@ async function loadAllTranslations({
440
440
 
441
441
  function extractHasTags(ast) {
442
442
  return ast.some(element => {
443
- if (icuMessageformatParser.isSelectElement(element)) {
443
+ if (icuMessageformatParser.isSelectElement(element) || icuMessageformatParser.isPluralElement(element)) {
444
444
  const children = Object.values(element.options).map(o => o.value);
445
445
  return children.some(child => extractHasTags(child));
446
446
  }
@@ -1,6 +1,6 @@
1
1
  import { existsSync, promises } from 'fs';
2
2
  import path from 'path';
3
- import { TYPE, parse, isSelectElement, isTagElement, isArgumentElement, isNumberElement, isPluralElement, isDateElement, isTimeElement } from '@formatjs/icu-messageformat-parser';
3
+ import { TYPE, parse, isSelectElement, isPluralElement, isTagElement, isArgumentElement, isNumberElement, isDateElement, isTimeElement } from '@formatjs/icu-messageformat-parser';
4
4
  import prettier from 'prettier';
5
5
  import chokidar from 'chokidar';
6
6
  import chalk from 'chalk';
@@ -424,7 +424,7 @@ async function loadAllTranslations({
424
424
 
425
425
  function extractHasTags(ast) {
426
426
  return ast.some(element => {
427
- if (isSelectElement(element)) {
427
+ if (isSelectElement(element) || isPluralElement(element)) {
428
428
  const children = Object.values(element.options).map(o => o.value);
429
429
  return children.some(child => extractHasTags(child));
430
430
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vocab/core",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
4
4
  "main": "dist/vocab-core.cjs.js",
5
5
  "module": "dist/vocab-core.esm.js",
6
6
  "exports": {