vite-plugin-drupal-t 1.0.4 → 1.0.5
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/dist/index.js +1 -1
- package/package.json +1 -1
- package/src/index.test.ts +5 -7
- package/src/index.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -44,7 +44,7 @@ export default function extractDrupalT(options = {}) {
|
|
|
44
44
|
// Format each translation as a comment.
|
|
45
45
|
// Replace '(Drupal)' with 'Drupal' for consistency.
|
|
46
46
|
// Drupal can find the translations it needs to include.
|
|
47
|
-
.map((translation) =>
|
|
47
|
+
.map((translation) => translation.replace('(Drupal)', 'Drupal').split('\n').map(line => `// ${line}`).join('\n'))
|
|
48
48
|
.join('\n');
|
|
49
49
|
this.emitFile({
|
|
50
50
|
type: 'asset',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-drupal-t",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "A Vite plugin that automatically extracts Drupal.t() and Drupal.formatPlural() translation calls for seamless internationalization",
|
|
5
5
|
"author": "Märt Rang <rang501@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
package/src/index.test.ts
CHANGED
|
@@ -161,7 +161,7 @@ multiline string\`);`;
|
|
|
161
161
|
const output = generateOutput(plugin);
|
|
162
162
|
|
|
163
163
|
expect(output).toContain('// Drupal.t(`This is a');
|
|
164
|
-
expect(output).toContain('multiline string`)');
|
|
164
|
+
expect(output).toContain('// multiline string`)');
|
|
165
165
|
});
|
|
166
166
|
|
|
167
167
|
it('should extract single-line template literals', () => {
|
|
@@ -193,7 +193,7 @@ Line 2\`, {});`;
|
|
|
193
193
|
const output = generateOutput(plugin);
|
|
194
194
|
|
|
195
195
|
expect(output).toContain('// Drupal.t(`Line 1');
|
|
196
|
-
expect(output).toContain('Line 2`, {})');
|
|
196
|
+
expect(output).toContain('// Line 2`, {})');
|
|
197
197
|
});
|
|
198
198
|
|
|
199
199
|
it('should extract multiline formatPlural strings', () => {
|
|
@@ -205,11 +205,9 @@ items\`, {});`;
|
|
|
205
205
|
callTransform(plugin, code, id);
|
|
206
206
|
const output = generateOutput(plugin);
|
|
207
207
|
|
|
208
|
-
expect(output).toContain('// Drupal.formatPlural(5,');
|
|
209
|
-
expect(output).toContain('`
|
|
210
|
-
expect(output).toContain('
|
|
211
|
-
expect(output).toContain('`Many');
|
|
212
|
-
expect(output).toContain('items`, {})');
|
|
208
|
+
expect(output).toContain('// Drupal.formatPlural(5, `One');
|
|
209
|
+
expect(output).toContain('// item`, `Many');
|
|
210
|
+
expect(output).toContain('// items`, {})');
|
|
213
211
|
});
|
|
214
212
|
});
|
|
215
213
|
|
package/src/index.ts
CHANGED
|
@@ -56,7 +56,7 @@ export default function extractDrupalT(options: ExtractDrupalTOptions = {}): Plu
|
|
|
56
56
|
// Format each translation as a comment.
|
|
57
57
|
// Replace '(Drupal)' with 'Drupal' for consistency.
|
|
58
58
|
// Drupal can find the translations it needs to include.
|
|
59
|
-
.map((translation) =>
|
|
59
|
+
.map((translation) => translation.replace('(Drupal)', 'Drupal').split('\n').map(line => `// ${line}`).join('\n'))
|
|
60
60
|
.join('\n');
|
|
61
61
|
|
|
62
62
|
this.emitFile({
|