@vocab/core 1.3.0 → 1.3.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.
- package/README.md +12 -3
- package/dist/declarations/src/compile.d.ts +1 -1
- package/dist/declarations/src/load-translations.d.ts +1 -1
- package/dist/declarations/src/validate/index.d.ts +1 -1
- package/dist/vocab-core.cjs.dev.js +1 -1
- package/dist/vocab-core.cjs.prod.js +1 -1
- package/dist/vocab-core.esm.js +2 -2
- package/package.json +1 -1
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
|
|
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
|
|
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: '
|
|
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,
|
|
@@ -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;
|
|
@@ -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
|
}
|
package/dist/vocab-core.esm.js
CHANGED
|
@@ -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,
|
|
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
|
}
|