vite-plugin-drupal-t 1.0.3 → 1.0.4

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.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Plugin } from 'rollup';
1
+ import type { Plugin } from 'vite';
2
2
  export interface ExtractDrupalTOptions {
3
3
  include?: string | string[];
4
4
  exclude?: string | string[];
package/dist/index.js CHANGED
@@ -4,6 +4,20 @@ export default function extractDrupalT(options = {}) {
4
4
  const translations = new Set();
5
5
  return {
6
6
  name: 'extract-drupal-t',
7
+ config() {
8
+ return {
9
+ build: {
10
+ rollupOptions: {
11
+ external: ['Drupal'],
12
+ output: {
13
+ globals: {
14
+ Drupal: 'Drupal',
15
+ },
16
+ },
17
+ },
18
+ },
19
+ };
20
+ },
7
21
  transform(code, id) {
8
22
  if (!filter(id))
9
23
  return null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-plugin-drupal-t",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
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",
@@ -40,7 +40,8 @@
40
40
  "formatPlural"
41
41
  ],
42
42
  "dependencies": {
43
- "@rollup/pluginutils": "^4.2.1"
43
+ "@rollup/pluginutils": "^4.2.1",
44
+ "ts-for-drupal-core": "^0.0.7"
44
45
  },
45
46
  "devDependencies": {
46
47
  "@types/estree": "^1.0.7",
package/src/index.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { createFilter } from '@rollup/pluginutils';
2
- import type { Plugin } from 'rollup';
2
+ import type { Plugin } from 'vite';
3
3
 
4
4
  export interface ExtractDrupalTOptions {
5
5
  include?: string | string[];
@@ -12,6 +12,20 @@ export default function extractDrupalT(options: ExtractDrupalTOptions = {}): Plu
12
12
 
13
13
  return {
14
14
  name: 'extract-drupal-t',
15
+ config() {
16
+ return {
17
+ build: {
18
+ rollupOptions: {
19
+ external: ['Drupal'],
20
+ output: {
21
+ globals: {
22
+ Drupal: 'Drupal',
23
+ },
24
+ },
25
+ },
26
+ },
27
+ };
28
+ },
15
29
  transform(code: string, id: string) {
16
30
  if (!filter(id)) return null;
17
31
 
package/src/drupal.d.ts DELETED
@@ -1,41 +0,0 @@
1
- declare namespace Drupal {
2
- /**
3
- * Translates a string to the current language.
4
- *
5
- * @param str
6
- * A string containing the English text to translate.
7
- * @param args
8
- * An object of replacements pairs to make after translation. Incidences
9
- * of any key in this array are replaced with the corresponding value.
10
- * @param options
11
- * Additional options for translation.
12
- * @returns
13
- * The translated string.
14
- */
15
- function t(str: string, args?: Record<string, string>, options?: { context?: string }): string;
16
-
17
- /**
18
- * Translates a string to the current language and formats it as a plural.
19
- *
20
- * @param count
21
- * The number to determine the plural form.
22
- * @param singular
23
- * The singular form of the string.
24
- * @param plural
25
- * The plural form of the string.
26
- * @param args
27
- * An object of replacements pairs to make after translation. Incidences
28
- * of any key in this array are replaced with the corresponding value.
29
- * @param options
30
- * Additional options for translation.
31
- * @returns
32
- * The translated string in the correct plural form.
33
- */
34
- function formatPlural(
35
- count: number,
36
- singular: string,
37
- plural: string,
38
- args?: Record<string, string>,
39
- options?: { context?: string }
40
- ): string;
41
- }