@wp-blocks/make-pot 0.0.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/ .prettierignore +3 -0
- package/.editorconfig +15 -0
- package/.eslintrc.json +12 -0
- package/.github/workflows/node.js.yml +33 -0
- package/jest.config.json +14 -0
- package/lib/cliArgs.d.ts +4 -0
- package/lib/cliArgs.js +177 -0
- package/lib/cliArgs.js.map +1 -0
- package/lib/consolidate.d.ts +2 -0
- package/lib/consolidate.js +27 -0
- package/lib/consolidate.js.map +1 -0
- package/lib/const.d.ts +26 -0
- package/lib/const.js +56 -0
- package/lib/const.js.map +1 -0
- package/lib/extractors-json.d.ts +9 -0
- package/lib/extractors-json.js +53 -0
- package/lib/extractors-json.js.map +1 -0
- package/lib/extractors-maps.d.ts +109 -0
- package/lib/extractors-maps.js +139 -0
- package/lib/extractors-maps.js.map +1 -0
- package/lib/extractors-php.d.ts +1 -0
- package/lib/extractors-php.js +24 -0
- package/lib/extractors-php.js.map +1 -0
- package/lib/extractors-text.d.ts +1 -0
- package/lib/extractors-text.js +21 -0
- package/lib/extractors-text.js.map +1 -0
- package/lib/extractors.d.ts +17 -0
- package/lib/extractors.js +128 -0
- package/lib/extractors.js.map +1 -0
- package/lib/fs.d.ts +2 -0
- package/lib/fs.js +51 -0
- package/lib/fs.js.map +1 -0
- package/lib/glob.d.ts +13 -0
- package/lib/glob.js +60 -0
- package/lib/glob.js.map +1 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +25 -0
- package/lib/index.js.map +1 -0
- package/lib/makePot.d.ts +2 -0
- package/lib/makePot.js +56 -0
- package/lib/makePot.js.map +1 -0
- package/lib/parser.d.ts +6 -0
- package/lib/parser.js +93 -0
- package/lib/parser.js.map +1 -0
- package/lib/tree.d.ts +2 -0
- package/lib/tree.js +77 -0
- package/lib/tree.js.map +1 -0
- package/lib/types.d.ts +46 -0
- package/lib/types.js +3 -0
- package/lib/types.js.map +1 -0
- package/lib/utils.d.ts +8 -0
- package/lib/utils.js +74 -0
- package/lib/utils.js.map +1 -0
- package/package.json +50 -0
- package/tests/consolidate.test.ts +77 -0
- package/tests/extract-2.test.ts +97 -0
- package/tests/extract.test.ts +380 -0
- package/tests/getFiles.test.ts +114 -0
- package/tests/getStrings.test.ts +149 -0
- package/tests/index.html +78 -0
- package/tests/ingnoreFunction.test.ts +177 -0
- package/tests/jsonParse.test.ts +60 -0
- package/tests/makePot.ts +46 -0
- package/tests/treeJs.test.ts +15 -0
- package/tests/treePhp.test.ts +30 -0
- package/tests/treeTs.test.ts +15 -0
- package/tests/utils.test.ts +28 -0
- package/tsconfig.json +35 -0
package/ .prettierignore
ADDED
package/.editorconfig
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# This file is for unifying the coding style for different editors and IDEs
|
|
2
|
+
# editorconfig.org
|
|
3
|
+
|
|
4
|
+
# WordPress Coding Standards
|
|
5
|
+
# https://make.wordpress.org/core/handbook/coding-standards/
|
|
6
|
+
|
|
7
|
+
root = true
|
|
8
|
+
|
|
9
|
+
[*]
|
|
10
|
+
charset = utf-8
|
|
11
|
+
end_of_line = lf
|
|
12
|
+
insert_final_newline = true
|
|
13
|
+
trim_trailing_whitespace = true
|
|
14
|
+
indent_size = 4
|
|
15
|
+
indent_style = tab
|
package/.eslintrc.json
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"env": {
|
|
3
|
+
"browser": true,
|
|
4
|
+
"node": true,
|
|
5
|
+
"commonjs": true,
|
|
6
|
+
"es2021": true
|
|
7
|
+
},
|
|
8
|
+
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
|
|
9
|
+
"parser": "@typescript-eslint/parser",
|
|
10
|
+
"plugins": ["@typescript-eslint"],
|
|
11
|
+
"root": true
|
|
12
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
|
|
2
|
+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs
|
|
3
|
+
|
|
4
|
+
name: Node.js CI
|
|
5
|
+
|
|
6
|
+
on:
|
|
7
|
+
push:
|
|
8
|
+
branches: [ "master" ]
|
|
9
|
+
pull_request:
|
|
10
|
+
branches: [ "master" ]
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
build:
|
|
14
|
+
|
|
15
|
+
runs-on: ${{ matrix.os }}
|
|
16
|
+
|
|
17
|
+
strategy:
|
|
18
|
+
matrix:
|
|
19
|
+
node-version: [lts/*, latest]
|
|
20
|
+
os: [ubuntu-latest, macos-latest, windows-latest]
|
|
21
|
+
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
|
|
22
|
+
|
|
23
|
+
steps:
|
|
24
|
+
- uses: actions/checkout@v3
|
|
25
|
+
- name: Use Node.js ${{ matrix.node-version }}
|
|
26
|
+
uses: actions/setup-node@v3
|
|
27
|
+
with:
|
|
28
|
+
node-version: ${{ matrix.node-version }}
|
|
29
|
+
cache: 'npm'
|
|
30
|
+
- run: npm install
|
|
31
|
+
- run: npm run build --if-present
|
|
32
|
+
- run: npm test
|
|
33
|
+
|
package/jest.config.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"preset": "ts-jest",
|
|
3
|
+
"testRegex": "(/tests/.*(test|spec))\\.tsx?$",
|
|
4
|
+
"transformIgnorePatterns": ["/node_modules/"],
|
|
5
|
+
"coverageThreshold": {
|
|
6
|
+
"global": {
|
|
7
|
+
"branches": 10,
|
|
8
|
+
"functions": 10,
|
|
9
|
+
"lines": 10,
|
|
10
|
+
"statements": 10
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"collectCoverageFrom": ["./src/**/*.{js,jsx,ts,tsx}", "!**/tests/**"]
|
|
14
|
+
}
|
package/lib/cliArgs.d.ts
ADDED
package/lib/cliArgs.js
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.parseCliArgs = exports.getArgs = void 0;
|
|
30
|
+
const yargs_1 = __importDefault(require("yargs"));
|
|
31
|
+
const helpers_1 = require("yargs/helpers");
|
|
32
|
+
const utils_1 = require("./utils");
|
|
33
|
+
const path = __importStar(require("path"));
|
|
34
|
+
const process = __importStar(require("process"));
|
|
35
|
+
const const_1 = require("./const");
|
|
36
|
+
function getArgs() {
|
|
37
|
+
const args = (0, yargs_1.default)((0, helpers_1.hideBin)(process.argv))
|
|
38
|
+
.help('h')
|
|
39
|
+
.alias('help', 'help')
|
|
40
|
+
.usage('Usage: $0 <source> [destination] [options]')
|
|
41
|
+
.positional('sourceDirectory', {
|
|
42
|
+
describe: 'Source directory',
|
|
43
|
+
type: 'string',
|
|
44
|
+
})
|
|
45
|
+
.positional('destination', {
|
|
46
|
+
describe: 'Destination directory',
|
|
47
|
+
type: 'string',
|
|
48
|
+
})
|
|
49
|
+
.options({
|
|
50
|
+
slug: {
|
|
51
|
+
describe: 'Plugin or theme slug',
|
|
52
|
+
type: 'string',
|
|
53
|
+
},
|
|
54
|
+
domain: {
|
|
55
|
+
describe: 'Text domain to look for in the source code',
|
|
56
|
+
type: 'string',
|
|
57
|
+
},
|
|
58
|
+
'skip-js': {
|
|
59
|
+
describe: 'Skip JavaScript files',
|
|
60
|
+
type: 'boolean',
|
|
61
|
+
},
|
|
62
|
+
'skip-php': {
|
|
63
|
+
describe: 'Skip PHP files',
|
|
64
|
+
type: 'boolean',
|
|
65
|
+
},
|
|
66
|
+
'skip-blade': {
|
|
67
|
+
describe: 'Skip Blade files',
|
|
68
|
+
type: 'boolean',
|
|
69
|
+
},
|
|
70
|
+
'skip-block-json': {
|
|
71
|
+
describe: 'Skip block.json files',
|
|
72
|
+
type: 'boolean',
|
|
73
|
+
},
|
|
74
|
+
'skip-theme-json': {
|
|
75
|
+
describe: 'Skip theme.json files',
|
|
76
|
+
type: 'boolean',
|
|
77
|
+
},
|
|
78
|
+
'skip-audit': {
|
|
79
|
+
describe: 'Skip auditing of strings',
|
|
80
|
+
type: 'boolean',
|
|
81
|
+
},
|
|
82
|
+
headers: {
|
|
83
|
+
describe: 'Headers',
|
|
84
|
+
type: 'string',
|
|
85
|
+
},
|
|
86
|
+
'file-comment': {
|
|
87
|
+
describe: 'File comment',
|
|
88
|
+
type: 'string',
|
|
89
|
+
},
|
|
90
|
+
'package-name': {
|
|
91
|
+
describe: 'Package name',
|
|
92
|
+
type: 'string',
|
|
93
|
+
},
|
|
94
|
+
location: {
|
|
95
|
+
describe: 'Include location information',
|
|
96
|
+
type: 'boolean',
|
|
97
|
+
},
|
|
98
|
+
'ignore-domain': {
|
|
99
|
+
describe: 'Ignore text domain',
|
|
100
|
+
type: 'boolean',
|
|
101
|
+
},
|
|
102
|
+
mergePaths: {
|
|
103
|
+
describe: 'Merge with existing POT file(s)',
|
|
104
|
+
type: 'string',
|
|
105
|
+
},
|
|
106
|
+
subtractPaths: {
|
|
107
|
+
describe: 'Subtract strings from existing POT file(s)',
|
|
108
|
+
type: 'string',
|
|
109
|
+
},
|
|
110
|
+
subtractAndMerge: {
|
|
111
|
+
describe: 'Subtract and merge strings from existing POT file(s)',
|
|
112
|
+
type: 'boolean',
|
|
113
|
+
},
|
|
114
|
+
include: {
|
|
115
|
+
describe: 'Include specific files',
|
|
116
|
+
type: 'string',
|
|
117
|
+
},
|
|
118
|
+
exclude: {
|
|
119
|
+
describe: 'Exclude specific files',
|
|
120
|
+
type: 'string',
|
|
121
|
+
},
|
|
122
|
+
silent: {
|
|
123
|
+
describe: 'No output to stdout',
|
|
124
|
+
type: 'boolean',
|
|
125
|
+
},
|
|
126
|
+
json: {
|
|
127
|
+
describe: 'output the json gettext data',
|
|
128
|
+
type: 'boolean',
|
|
129
|
+
},
|
|
130
|
+
})
|
|
131
|
+
.parseSync();
|
|
132
|
+
return parseCliArgs(args);
|
|
133
|
+
}
|
|
134
|
+
exports.getArgs = getArgs;
|
|
135
|
+
function parseCliArgs(args) {
|
|
136
|
+
const inputPath = typeof args._[0] === 'string' ? args._[0] : '.';
|
|
137
|
+
const outputPath = typeof args._[1] === 'string' ? args._[1] : '.';
|
|
138
|
+
const parsedArgs = {
|
|
139
|
+
slug: args.slug && typeof args.slug === 'string'
|
|
140
|
+
? args.slug
|
|
141
|
+
: path.basename(process.cwd()),
|
|
142
|
+
domain: args?.domain ?? 'generic',
|
|
143
|
+
paths: {
|
|
144
|
+
cwd: path.relative(process.cwd(), inputPath),
|
|
145
|
+
out: path.relative(process.cwd(), outputPath),
|
|
146
|
+
},
|
|
147
|
+
options: {
|
|
148
|
+
ignoreDomain: !!args?.ignoreDomain,
|
|
149
|
+
packageName: String(args.packageName ?? ''),
|
|
150
|
+
silent: !!args.silent,
|
|
151
|
+
json: !!args.json,
|
|
152
|
+
location: !!args?.location,
|
|
153
|
+
skip: {
|
|
154
|
+
js: !!args.skipJs,
|
|
155
|
+
php: !!args.skipPhp,
|
|
156
|
+
blade: !!args.skipBlade,
|
|
157
|
+
blockJson: !!args.skipBlockJson,
|
|
158
|
+
themeJson: !!args.skipThemeJson,
|
|
159
|
+
audit: !!args.skipAudit,
|
|
160
|
+
},
|
|
161
|
+
},
|
|
162
|
+
headers: {
|
|
163
|
+
fileComment: args.fileComment ?? '',
|
|
164
|
+
},
|
|
165
|
+
patterns: {
|
|
166
|
+
mergePaths: (0, utils_1.stringstring)(args.mergePaths) ?? [],
|
|
167
|
+
subtractPaths: (0, utils_1.stringstring)(args.subtractPaths) ?? [],
|
|
168
|
+
subtractAndMerge: !!args.subtractAndMerge,
|
|
169
|
+
include: (0, utils_1.stringstring)(args.include) ?? ['**'],
|
|
170
|
+
exclude: (0, utils_1.stringstring)(args.exclude) ?? const_1.DEFAULT_EXCLUDED_PATH,
|
|
171
|
+
},
|
|
172
|
+
};
|
|
173
|
+
parsedArgs.paths.root = args.root ? String(args.root) : undefined;
|
|
174
|
+
return parsedArgs;
|
|
175
|
+
}
|
|
176
|
+
exports.parseCliArgs = parseCliArgs;
|
|
177
|
+
//# sourceMappingURL=cliArgs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cliArgs.js","sourceRoot":"","sources":["../src/cliArgs.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAAyB;AACzB,2CAAuC;AACvC,mCAAsC;AACtC,2CAA4B;AAC5B,iDAAkC;AAClC,mCAA+C;AAQ/C,SAAgB,OAAO;IACt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O,EAAE,IAAA,oBAAY,EAAC,IAAI,CAAC,OAAiB,CAAC,IAAI,CAAC,IAAI,CAAC;YACvD,OAAO,EACN,IAAA,oBAAY,EAAC,IAAI,CAAC,OAAiB,CAAC,IAAI,6BAAqB;SAC9D;KACD,CAAA;IACD,UAAU,CAAC,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;IAEjE,OAAO,UAAU,CAAA;AAClB,CAAC;AAlDD,oCAkDC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.consolidate = void 0;
|
|
4
|
+
function consolidate(translationsArray) {
|
|
5
|
+
const mergedTranslations = {};
|
|
6
|
+
translationsArray.forEach((translations) => {
|
|
7
|
+
Object.entries(translations).forEach(([context, contextTranslations]) => {
|
|
8
|
+
if (!mergedTranslations[context]) {
|
|
9
|
+
mergedTranslations[context] = {};
|
|
10
|
+
}
|
|
11
|
+
Object.entries(contextTranslations).forEach(([msgid, translation]) => {
|
|
12
|
+
if (!mergedTranslations[context][msgid]) {
|
|
13
|
+
mergedTranslations[context][msgid] = {
|
|
14
|
+
msgctxt: context !== '' ? context : undefined,
|
|
15
|
+
msgid: msgid ?? '',
|
|
16
|
+
msgid_plural: translation.msgid_plural,
|
|
17
|
+
msgstr: translation.msgstr,
|
|
18
|
+
comments: translation.comments,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
return mergedTranslations;
|
|
25
|
+
}
|
|
26
|
+
exports.consolidate = consolidate;
|
|
27
|
+
//# sourceMappingURL=consolidate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"consolidate.js","sourceRoot":"","sources":["../src/consolidate.ts"],"names":[],"mappings":";;;AAUA,SAAgB,WAAW,CAC1B,iBAAuC;IAEvC,MAAM,kBAAkB,GAAuB,EAAE,CAAA;IAEjD,iBAAiB,CAAC,OAAO,CAAC,CAAC,YAAY,EAAE,EAAE;QAC1C,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,OAAO,CACnC,CAAC,CAAC,OAAO,EAAE,mBAAmB,CAAC,EAAE,EAAE;YAClC,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,EAAE,CAAC;gBAClC,kBAAkB,CAAC,OAAO,CAAC,GAAG,EAAE,CAAA;YACjC,CAAC;YAED,MAAM,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC,OAAO,CAC1C,CAAC,CAAC,KAAK,EAAE,WAAW,CAAC,EAAE,EAAE;gBACxB,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC;oBACzC,kBAAkB,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,GAAG;wBACpC,OAAO,EAAE,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS;wBAC7C,KAAK,EAAE,KAAK,IAAI,EAAE;wBAClB,YAAY,EAAE,WAAW,CAAC,YAAY;wBACtC,MAAM,EAAE,WAAW,CAAC,MAAM;wBAC1B,QAAQ,EAAE,WAAW,CAAC,QAAQ;qBAC9B,CAAA;gBACF,CAAC;YACF,CAAC,CACD,CAAA;QACF,CAAC,CACD,CAAA;IACF,CAAC,CAAC,CAAA;IAEF,OAAO,kBAAkB,CAAA;AAC1B,CAAC;AA9BD,kCA8BC"}
|
package/lib/const.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export declare const DEFAULT_EXCLUDED_PATH: string[];
|
|
2
|
+
export declare const allowedFiles: string[];
|
|
3
|
+
export declare const i18nFunctions: {
|
|
4
|
+
__: string;
|
|
5
|
+
esc_attr__: string;
|
|
6
|
+
esc_html__: string;
|
|
7
|
+
esc_xml__: string;
|
|
8
|
+
_e: string;
|
|
9
|
+
esc_attr_e: string;
|
|
10
|
+
esc_html_e: string;
|
|
11
|
+
esc_xml_e: string;
|
|
12
|
+
_x: string;
|
|
13
|
+
_ex: string;
|
|
14
|
+
esc_attr_x: string;
|
|
15
|
+
esc_html_x: string;
|
|
16
|
+
esc_xml_x: string;
|
|
17
|
+
_n: string;
|
|
18
|
+
_nx: string;
|
|
19
|
+
_n_noop: string;
|
|
20
|
+
_nx_noop: string;
|
|
21
|
+
_: string;
|
|
22
|
+
_c: string;
|
|
23
|
+
_nc: string;
|
|
24
|
+
__ngettext: string;
|
|
25
|
+
__ngettext_noop: string;
|
|
26
|
+
};
|
package/lib/const.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.i18nFunctions = exports.allowedFiles = exports.DEFAULT_EXCLUDED_PATH = void 0;
|
|
4
|
+
exports.DEFAULT_EXCLUDED_PATH = [
|
|
5
|
+
'.git',
|
|
6
|
+
'node_modules',
|
|
7
|
+
'vendor',
|
|
8
|
+
'build',
|
|
9
|
+
'dist',
|
|
10
|
+
'uploads',
|
|
11
|
+
'Gruntfile.js',
|
|
12
|
+
'webpack.config.js',
|
|
13
|
+
'**/*.min.js',
|
|
14
|
+
'tsconfig.js',
|
|
15
|
+
'**.test.**',
|
|
16
|
+
'tests',
|
|
17
|
+
];
|
|
18
|
+
exports.allowedFiles = [
|
|
19
|
+
'php',
|
|
20
|
+
'js',
|
|
21
|
+
'jsx',
|
|
22
|
+
'ts',
|
|
23
|
+
'tsx',
|
|
24
|
+
'mjs',
|
|
25
|
+
'cjs',
|
|
26
|
+
'txt',
|
|
27
|
+
'css',
|
|
28
|
+
'html',
|
|
29
|
+
'json',
|
|
30
|
+
'md',
|
|
31
|
+
];
|
|
32
|
+
exports.i18nFunctions = {
|
|
33
|
+
__: 'text_domain',
|
|
34
|
+
esc_attr__: 'text_domain',
|
|
35
|
+
esc_html__: 'text_domain',
|
|
36
|
+
esc_xml__: 'text_domain',
|
|
37
|
+
_e: 'text_domain',
|
|
38
|
+
esc_attr_e: 'text_domain',
|
|
39
|
+
esc_html_e: 'text_domain',
|
|
40
|
+
esc_xml_e: 'text_domain',
|
|
41
|
+
_x: 'text_context_domain',
|
|
42
|
+
_ex: 'text_context_domain',
|
|
43
|
+
esc_attr_x: 'text_context_domain',
|
|
44
|
+
esc_html_x: 'text_context_domain',
|
|
45
|
+
esc_xml_x: 'text_context_domain',
|
|
46
|
+
_n: 'single_plural_number_domain',
|
|
47
|
+
_nx: 'single_plural_number_context_domain',
|
|
48
|
+
_n_noop: 'single_plural_domain',
|
|
49
|
+
_nx_noop: 'single_plural_context_domain',
|
|
50
|
+
_: 'gettext',
|
|
51
|
+
_c: 'text_domain',
|
|
52
|
+
_nc: 'single_plural_number_domain',
|
|
53
|
+
__ngettext: 'single_plural_number_domain',
|
|
54
|
+
__ngettext_noop: 'single_plural_domain',
|
|
55
|
+
};
|
|
56
|
+
//# sourceMappingURL=const.js.map
|
package/lib/const.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"const.js","sourceRoot":"","sources":["../src/const.ts"],"names":[],"mappings":";;;AAIa,QAAA,qBAAqB,GAAG;IACpC,MAAM;IACN,cAAc;IACd,QAAQ;IACR,OAAO;IACP,MAAM;IACN,SAAS;IACT,cAAc;IACd,mBAAmB;IACnB,aAAa;IACb,aAAa;IACb,YAAY;IACZ,OAAO;CACP,CAAA;AAEY,QAAA,YAAY,GAAG;IAC3B,KAAK;IACL,IAAI;IACJ,KAAK;IACL,IAAI;IACJ,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,MAAM;IACN,MAAM;IACN,IAAI;CACJ,CAAA;AAIY,QAAA,aAAa,GAAG;IAC5B,EAAE,EAAE,aAAa;IACjB,UAAU,EAAE,aAAa;IACzB,UAAU,EAAE,aAAa;IACzB,SAAS,EAAE,aAAa;IACxB,EAAE,EAAE,aAAa;IACjB,UAAU,EAAE,aAAa;IACzB,UAAU,EAAE,aAAa;IACzB,SAAS,EAAE,aAAa;IACxB,EAAE,EAAE,qBAAqB;IACzB,GAAG,EAAE,qBAAqB;IAC1B,UAAU,EAAE,qBAAqB;IACjC,UAAU,EAAE,qBAAqB;IACjC,SAAS,EAAE,qBAAqB;IAChC,EAAE,EAAE,6BAA6B;IACjC,GAAG,EAAE,qCAAqC;IAC1C,OAAO,EAAE,sBAAsB;IAC/B,QAAQ,EAAE,8BAA8B;IAGxC,CAAC,EAAE,SAAS;IAGZ,EAAE,EAAE,aAAa;IACjB,GAAG,EAAE,6BAA6B;IAClC,UAAU,EAAE,6BAA6B;IACzC,eAAe,EAAE,sBAAsB;CACvC,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { TranslationStrings } from './types';
|
|
2
|
+
import { GetTextTranslation } from 'gettext-parser';
|
|
3
|
+
export declare function parseJsonFile(opts: {
|
|
4
|
+
sourceCode: string;
|
|
5
|
+
filename: 'block.json' | 'theme.json';
|
|
6
|
+
filepath: string;
|
|
7
|
+
}): TranslationStrings;
|
|
8
|
+
export declare function getJsonComment(key: string, type?: 'block.json' | 'theme.json'): string;
|
|
9
|
+
export declare function jsonString(key: string, data: string, path: string, type?: 'block.json' | 'theme.json'): GetTextTranslation;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.jsonString = exports.getJsonComment = exports.parseJsonFile = void 0;
|
|
4
|
+
const extractors_1 = require("./extractors");
|
|
5
|
+
const extractors_maps_1 = require("./extractors-maps");
|
|
6
|
+
function findValuesInJson(block, jsonData) {
|
|
7
|
+
const result = {};
|
|
8
|
+
const searchValues = (block, json) => {
|
|
9
|
+
for (const key in block) {
|
|
10
|
+
if (typeof block[key] === 'object' &&
|
|
11
|
+
typeof json[key] === 'object' &&
|
|
12
|
+
key in block) {
|
|
13
|
+
searchValues(block[key], json[key]);
|
|
14
|
+
}
|
|
15
|
+
else if (json[key] !== undefined) {
|
|
16
|
+
result[key] = json[key];
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
searchValues(block, jsonData);
|
|
21
|
+
return result;
|
|
22
|
+
}
|
|
23
|
+
function parseJsonFile(opts) {
|
|
24
|
+
let parsed = null;
|
|
25
|
+
const JsonData = JSON.parse(opts.sourceCode);
|
|
26
|
+
parsed = findValuesInJson(JsonData, opts.filename === 'block.json' ? extractors_maps_1.blockJson : extractors_maps_1.themeJson);
|
|
27
|
+
if (parsed) {
|
|
28
|
+
return (0, extractors_1.yieldParsedData)(parsed, opts.filename, opts.filepath);
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
return {};
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.parseJsonFile = parseJsonFile;
|
|
35
|
+
function getJsonComment(key, type) {
|
|
36
|
+
const comments = type === 'block.json' ? extractors_maps_1.blockJson : extractors_maps_1.themeJson;
|
|
37
|
+
return key in Object.values(comments)
|
|
38
|
+
? comments[key]
|
|
39
|
+
: key;
|
|
40
|
+
}
|
|
41
|
+
exports.getJsonComment = getJsonComment;
|
|
42
|
+
function jsonString(key, data, path, type) {
|
|
43
|
+
return {
|
|
44
|
+
msgstr: [],
|
|
45
|
+
msgid: getJsonComment(key, type),
|
|
46
|
+
msgctxt: data,
|
|
47
|
+
comments: {
|
|
48
|
+
reference: `${path}`,
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
exports.jsonString = jsonString;
|
|
53
|
+
//# sourceMappingURL=extractors-json.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extractors-json.js","sourceRoot":"","sources":["../src/extractors-json.ts"],"names":[],"mappings":";;;AACA,6CAA8C;AAC9C,uDAA8E;AAU9E,SAAS,gBAAgB,CACxB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,IAAI,KAAK,YAAY,CAAC,CAAC,CAAC,2BAAS,CAAC,CAAC,CAAC,2BAAS,CAAA;IAC9D,OAAO,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC;QACpC,CAAC,CAAC,QAAQ,CAAC,GAA4B,CAAC;QACxC,CAAC,CAAC,GAAG,CAAA;AACP,CAAC;AARD,wCAQC;AAWD,SAAgB,UAAU,CACzB,GAAW,EACX,IAAY,EACZ,IAAY,EACZ,IAAkC;IAElC,OAAO;QACN,MAAM,EAAE,EAAE;QACV,KAAK,EAAE,cAAc,CAAC,GAAG,EAAE,IAAI,CAAC;QAChC,OAAO,EAAE,IAAI;QACb,QAAQ,EAAE;YACT,SAAS,EAAE,GAAG,IAAI,EAAE;SACF;KACnB,CAAA;AACF,CAAC;AAdD,gCAcC"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
export declare const themeJson: {
|
|
2
|
+
readonly title: "Style variation name";
|
|
3
|
+
readonly settings: {
|
|
4
|
+
readonly typography: {
|
|
5
|
+
readonly fontSizes: readonly [{
|
|
6
|
+
readonly name: "Font size name";
|
|
7
|
+
}];
|
|
8
|
+
readonly fontFamilies: readonly [{
|
|
9
|
+
readonly name: "Font family name";
|
|
10
|
+
}];
|
|
11
|
+
};
|
|
12
|
+
readonly color: {
|
|
13
|
+
readonly palette: readonly [{
|
|
14
|
+
readonly name: "Color name";
|
|
15
|
+
}];
|
|
16
|
+
readonly gradients: readonly [{
|
|
17
|
+
readonly name: "Gradient name";
|
|
18
|
+
}];
|
|
19
|
+
readonly duotone: readonly [{
|
|
20
|
+
readonly name: "Duotone name";
|
|
21
|
+
}];
|
|
22
|
+
};
|
|
23
|
+
readonly spacing: {
|
|
24
|
+
readonly spacingSizes: readonly [{
|
|
25
|
+
readonly name: "Space size name";
|
|
26
|
+
}];
|
|
27
|
+
};
|
|
28
|
+
readonly blocks: {
|
|
29
|
+
readonly '*': {
|
|
30
|
+
readonly typography: {
|
|
31
|
+
readonly fontSizes: readonly [{
|
|
32
|
+
readonly name: "Font size name";
|
|
33
|
+
}];
|
|
34
|
+
readonly fontFamilies: readonly [{
|
|
35
|
+
readonly name: "Font family name";
|
|
36
|
+
}];
|
|
37
|
+
};
|
|
38
|
+
readonly color: {
|
|
39
|
+
readonly palette: readonly [{
|
|
40
|
+
readonly name: "Color name";
|
|
41
|
+
}];
|
|
42
|
+
readonly gradients: readonly [{
|
|
43
|
+
readonly name: "Gradient name";
|
|
44
|
+
}];
|
|
45
|
+
};
|
|
46
|
+
readonly spacing: {
|
|
47
|
+
readonly spacingSizes: readonly [{
|
|
48
|
+
readonly name: "Space size name";
|
|
49
|
+
}];
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
readonly customTemplates: readonly [{
|
|
55
|
+
readonly title: "Custom template name";
|
|
56
|
+
}];
|
|
57
|
+
readonly templateParts: readonly [{
|
|
58
|
+
readonly title: "Template part name";
|
|
59
|
+
}];
|
|
60
|
+
};
|
|
61
|
+
export type ThemeJson = typeof themeJson;
|
|
62
|
+
export type ThemeJsonKeys = keyof typeof themeJson;
|
|
63
|
+
export declare const blockJson: {
|
|
64
|
+
readonly title: "block title";
|
|
65
|
+
readonly description: "block description";
|
|
66
|
+
readonly keywords: readonly ["block keyword"];
|
|
67
|
+
readonly styles: readonly [{
|
|
68
|
+
readonly label: "block style label";
|
|
69
|
+
}];
|
|
70
|
+
readonly variations: readonly [{
|
|
71
|
+
readonly title: "block variation title";
|
|
72
|
+
readonly description: "block variation description";
|
|
73
|
+
readonly keywords: readonly ["block variation keyword"];
|
|
74
|
+
}];
|
|
75
|
+
};
|
|
76
|
+
export type BlockJson = typeof blockJson;
|
|
77
|
+
export type BlockJsonKeys = keyof typeof blockJson;
|
|
78
|
+
export declare const pkgJsonHeaders: {
|
|
79
|
+
name: string;
|
|
80
|
+
url: string;
|
|
81
|
+
description: string;
|
|
82
|
+
author: string;
|
|
83
|
+
version: string;
|
|
84
|
+
bugs: string;
|
|
85
|
+
license: string;
|
|
86
|
+
repository: string;
|
|
87
|
+
};
|
|
88
|
+
export declare const pluginHeaders: {
|
|
89
|
+
readonly name: "Plugin Name";
|
|
90
|
+
readonly url: "Plugin URI";
|
|
91
|
+
readonly description: "Description";
|
|
92
|
+
readonly author: "Author";
|
|
93
|
+
readonly authorUrl: "Author URI";
|
|
94
|
+
readonly version: "Version";
|
|
95
|
+
readonly license: "License";
|
|
96
|
+
readonly domainPath: "Domain Path";
|
|
97
|
+
readonly textDomain: "Text Domain";
|
|
98
|
+
};
|
|
99
|
+
export declare const themeHeaders: {
|
|
100
|
+
readonly name: "Theme Name";
|
|
101
|
+
readonly url: "Theme URI";
|
|
102
|
+
readonly description: "Description";
|
|
103
|
+
readonly author: "Author";
|
|
104
|
+
readonly authorUrl: "Author URI";
|
|
105
|
+
readonly version: "Version";
|
|
106
|
+
readonly license: "License";
|
|
107
|
+
readonly domainPath: "Domain Path";
|
|
108
|
+
readonly textDomain: "Text Domain";
|
|
109
|
+
};
|