@discord/intl-loader-core 0.10.4 → 0.11.1-rc.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/index.js +4 -0
- package/package.json +2 -2
- package/src/processing.js +31 -2
- package/types/index.d.ts +3 -1
- package/types/src/processing.d.ts +21 -0
package/index.js
CHANGED
|
@@ -7,6 +7,8 @@ const {
|
|
|
7
7
|
|
|
8
8
|
const { database } = require('./src/database');
|
|
9
9
|
const {
|
|
10
|
+
findAllMessagesFiles,
|
|
11
|
+
processAllMessagesFiles,
|
|
10
12
|
generateTypeDefinitions,
|
|
11
13
|
processDefinitionsFile,
|
|
12
14
|
processTranslationsFile,
|
|
@@ -31,5 +33,7 @@ module.exports = {
|
|
|
31
33
|
processDefinitionsFile,
|
|
32
34
|
processTranslationsFile,
|
|
33
35
|
precompileFileForLocale,
|
|
36
|
+
findAllMessagesFiles,
|
|
37
|
+
processAllMessagesFiles,
|
|
34
38
|
watcher,
|
|
35
39
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@discord/intl-loader-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.1-rc.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Core utilities for writing loaders and transformers using @discord/intl",
|
|
6
6
|
"author": "Jon Egeland",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"chokidar": "^3.6.0",
|
|
30
30
|
"debug": "^4.3.6",
|
|
31
31
|
"fast-glob": "^3.3.2",
|
|
32
|
-
"@discord/intl-message-database": "0.
|
|
32
|
+
"@discord/intl-message-database": "0.11.1-rc.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@types/debug": "^4.1.12",
|
package/src/processing.js
CHANGED
|
@@ -15,7 +15,7 @@ const { findAllTranslationFiles, getLocaleFromTranslationsFileName } = require('
|
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* @param {string} sourcePath
|
|
18
|
-
* @param {import('
|
|
18
|
+
* @param {import('../types').IntlSourceFile} sourceFile
|
|
19
19
|
*/
|
|
20
20
|
function debugSourceFile(sourcePath, sourceFile) {
|
|
21
21
|
debug(
|
|
@@ -26,7 +26,7 @@ function debugSourceFile(sourcePath, sourceFile) {
|
|
|
26
26
|
/**
|
|
27
27
|
*
|
|
28
28
|
* @param {string} sourcePath Path of the source file being processed, for debug logging
|
|
29
|
-
* @param {import('
|
|
29
|
+
* @param {import('../types').IntlSourceFile} sourceFile SourceFile object from the database used to find translations.
|
|
30
30
|
* @param {string} translationsPath Fully-resolved path to the directory for translations.
|
|
31
31
|
* @returns {Record<string, string>}
|
|
32
32
|
*/
|
|
@@ -43,6 +43,33 @@ function buildTranslationsLocaleMap(sourcePath, sourceFile, translationsPath) {
|
|
|
43
43
|
return map;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
+
/**
|
|
47
|
+
* Scan the entire file system within the given `directories` to find all files that can be treated
|
|
48
|
+
* as messages definitions _or_ translations.
|
|
49
|
+
*
|
|
50
|
+
* @param {string[]} directories
|
|
51
|
+
* @param {string} defaultLocale
|
|
52
|
+
* @returns {import('../types').IntlMessagesFileDescriptor[]}
|
|
53
|
+
*/
|
|
54
|
+
function findAllMessagesFiles(directories, defaultLocale = 'en-US') {
|
|
55
|
+
return database.findAllMessagesFiles(directories, defaultLocale);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Iterate the given `files`, processing each one's content into the database. Processing is done
|
|
60
|
+
* in parallel using native acceleration, and returns the list of all file names that were used.
|
|
61
|
+
*
|
|
62
|
+
* Note that this method _only_ operates by reading file contents from the system, it is not
|
|
63
|
+
* possible to supply preloaded content through a Buffer in the same way as `processDefinitionsFile`
|
|
64
|
+
* with a `sourceContent` argument.
|
|
65
|
+
*
|
|
66
|
+
* @param {import('../types').IntlMessagesFileDescriptor[]} files
|
|
67
|
+
* @returns {string[]}
|
|
68
|
+
*/
|
|
69
|
+
function processAllMessagesFiles(files) {
|
|
70
|
+
return database.processAllMessagesFiles(files);
|
|
71
|
+
}
|
|
72
|
+
|
|
46
73
|
/**
|
|
47
74
|
* @param {string} sourcePath
|
|
48
75
|
* @param {string=} sourceContent
|
|
@@ -188,6 +215,8 @@ function generateTypeDefinitions(sourcePath, outputFile, allowNullability = fals
|
|
|
188
215
|
}
|
|
189
216
|
|
|
190
217
|
module.exports = {
|
|
218
|
+
findAllMessagesFiles,
|
|
219
|
+
processAllMessagesFiles,
|
|
191
220
|
generateTypeDefinitions,
|
|
192
221
|
precompileFileForLocale,
|
|
193
222
|
processDefinitionsFile,
|
package/types/index.d.ts
CHANGED
|
@@ -10,5 +10,7 @@ import { isMessageTranslationsFile } from "@discord/intl-message-database";
|
|
|
10
10
|
import { processDefinitionsFile } from "./src/processing";
|
|
11
11
|
import { processTranslationsFile } from "./src/processing";
|
|
12
12
|
import { precompileFileForLocale } from "./src/processing";
|
|
13
|
+
import { findAllMessagesFiles } from "./src/processing";
|
|
14
|
+
import { processAllMessagesFiles } from "./src/processing";
|
|
13
15
|
import watcher = require("./src/watcher");
|
|
14
|
-
export { IntlCompiledMessageFormat, MessageDefinitionsTransformer, database, findAllTranslationFiles, getLocaleFromTranslationsFileName, generateTypeDefinitions, hashMessageKey, isMessageDefinitionsFile, isMessageTranslationsFile, processDefinitionsFile, processTranslationsFile, precompileFileForLocale, watcher };
|
|
16
|
+
export { IntlCompiledMessageFormat, MessageDefinitionsTransformer, database, findAllTranslationFiles, getLocaleFromTranslationsFileName, generateTypeDefinitions, hashMessageKey, isMessageDefinitionsFile, isMessageTranslationsFile, processDefinitionsFile, processTranslationsFile, precompileFileForLocale, findAllMessagesFiles, processAllMessagesFiles, watcher };
|
|
@@ -2,6 +2,27 @@ export type IntlPrecompileOptions = {
|
|
|
2
2
|
format?: IntlCompiledMessageFormat;
|
|
3
3
|
bundleSecrets?: boolean;
|
|
4
4
|
};
|
|
5
|
+
/**
|
|
6
|
+
* Scan the entire file system within the given `directories` to find all files that can be treated
|
|
7
|
+
* as messages definitions _or_ translations.
|
|
8
|
+
*
|
|
9
|
+
* @param {string[]} directories
|
|
10
|
+
* @param {string} defaultLocale
|
|
11
|
+
* @returns {import('../types').IntlMessagesFileDescriptor[]}
|
|
12
|
+
*/
|
|
13
|
+
export function findAllMessagesFiles(directories: string[], defaultLocale?: string): import("../types").IntlMessagesFileDescriptor[];
|
|
14
|
+
/**
|
|
15
|
+
* Iterate the given `files`, processing each one's content into the database. Processing is done
|
|
16
|
+
* in parallel using native acceleration, and returns the list of all file names that were used.
|
|
17
|
+
*
|
|
18
|
+
* Note that this method _only_ operates by reading file contents from the system, it is not
|
|
19
|
+
* possible to supply preloaded content through a Buffer in the same way as `processDefinitionsFile`
|
|
20
|
+
* with a `sourceContent` argument.
|
|
21
|
+
*
|
|
22
|
+
* @param {import('../types').IntlMessagesFileDescriptor[]} files
|
|
23
|
+
* @returns {string[]}
|
|
24
|
+
*/
|
|
25
|
+
export function processAllMessagesFiles(files: import("../types").IntlMessagesFileDescriptor[]): string[];
|
|
5
26
|
/**
|
|
6
27
|
* Generate a `.d.ts` file containing TypeScript type definitions for all of the messages defined in
|
|
7
28
|
* `sourcePath`. This method does not process `sourcePath` at all, meaning it expects the database
|