gsheets-i18n 1.0.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.
Files changed (68) hide show
  1. package/README.md +414 -0
  2. package/dist/cjs/cli/index.js +125 -0
  3. package/dist/cjs/cli/index.js.map +1 -0
  4. package/dist/cjs/index.js +57 -0
  5. package/dist/cjs/index.js.map +1 -0
  6. package/dist/cjs/lib/auth.js +34 -0
  7. package/dist/cjs/lib/auth.js.map +1 -0
  8. package/dist/cjs/lib/defaultKeyMap.js +106 -0
  9. package/dist/cjs/lib/defaultKeyMap.js.map +1 -0
  10. package/dist/cjs/lib/driveClient.js +50 -0
  11. package/dist/cjs/lib/driveClient.js.map +1 -0
  12. package/dist/cjs/lib/folderExtractor.js +63 -0
  13. package/dist/cjs/lib/folderExtractor.js.map +1 -0
  14. package/dist/cjs/lib/parser.js +120 -0
  15. package/dist/cjs/lib/parser.js.map +1 -0
  16. package/dist/cjs/lib/sheetExtractor.js +52 -0
  17. package/dist/cjs/lib/sheetExtractor.js.map +1 -0
  18. package/dist/cjs/lib/sheetsClient.js +37 -0
  19. package/dist/cjs/lib/sheetsClient.js.map +1 -0
  20. package/dist/cjs/lib/writer.js +33 -0
  21. package/dist/cjs/lib/writer.js.map +1 -0
  22. package/dist/cjs/types/index.js +4 -0
  23. package/dist/cjs/types/index.js.map +1 -0
  24. package/dist/esm/cli/index.js +123 -0
  25. package/dist/esm/cli/index.js.map +1 -0
  26. package/dist/esm/index.js +54 -0
  27. package/dist/esm/index.js.map +1 -0
  28. package/dist/esm/lib/auth.js +31 -0
  29. package/dist/esm/lib/auth.js.map +1 -0
  30. package/dist/esm/lib/defaultKeyMap.js +103 -0
  31. package/dist/esm/lib/defaultKeyMap.js.map +1 -0
  32. package/dist/esm/lib/driveClient.js +43 -0
  33. package/dist/esm/lib/driveClient.js.map +1 -0
  34. package/dist/esm/lib/folderExtractor.js +60 -0
  35. package/dist/esm/lib/folderExtractor.js.map +1 -0
  36. package/dist/esm/lib/parser.js +114 -0
  37. package/dist/esm/lib/parser.js.map +1 -0
  38. package/dist/esm/lib/sheetExtractor.js +49 -0
  39. package/dist/esm/lib/sheetExtractor.js.map +1 -0
  40. package/dist/esm/lib/sheetsClient.js +33 -0
  41. package/dist/esm/lib/sheetsClient.js.map +1 -0
  42. package/dist/esm/lib/writer.js +30 -0
  43. package/dist/esm/lib/writer.js.map +1 -0
  44. package/dist/esm/types/index.js +3 -0
  45. package/dist/esm/types/index.js.map +1 -0
  46. package/dist/types/cli/index.d.ts +3 -0
  47. package/dist/types/cli/index.d.ts.map +1 -0
  48. package/dist/types/index.d.ts +21 -0
  49. package/dist/types/index.d.ts.map +1 -0
  50. package/dist/types/lib/auth.d.ts +9 -0
  51. package/dist/types/lib/auth.d.ts.map +1 -0
  52. package/dist/types/lib/defaultKeyMap.d.ts +9 -0
  53. package/dist/types/lib/defaultKeyMap.d.ts.map +1 -0
  54. package/dist/types/lib/driveClient.d.ts +20 -0
  55. package/dist/types/lib/driveClient.d.ts.map +1 -0
  56. package/dist/types/lib/folderExtractor.d.ts +23 -0
  57. package/dist/types/lib/folderExtractor.d.ts.map +1 -0
  58. package/dist/types/lib/parser.d.ts +60 -0
  59. package/dist/types/lib/parser.d.ts.map +1 -0
  60. package/dist/types/lib/sheetExtractor.d.ts +26 -0
  61. package/dist/types/lib/sheetExtractor.d.ts.map +1 -0
  62. package/dist/types/lib/sheetsClient.d.ts +15 -0
  63. package/dist/types/lib/sheetsClient.d.ts.map +1 -0
  64. package/dist/types/lib/writer.d.ts +9 -0
  65. package/dist/types/lib/writer.d.ts.map +1 -0
  66. package/dist/types/types/index.d.ts +153 -0
  67. package/dist/types/types/index.d.ts.map +1 -0
  68. package/package.json +62 -0
@@ -0,0 +1,20 @@
1
+ import { google } from "googleapis";
2
+ type AuthClient = Parameters<typeof google.drive>[0]["auth"];
3
+ export interface DriveFile {
4
+ id: string;
5
+ name: string;
6
+ mimeType: string;
7
+ }
8
+ /**
9
+ * Lists all files and sub-folders directly inside a Drive folder.
10
+ * Handles pagination automatically.
11
+ */
12
+ export declare function listFolderContents(auth: AuthClient, folderId: string): Promise<DriveFile[]>;
13
+ export declare function isSpreadsheet(file: DriveFile): boolean;
14
+ export declare function isFolder(file: DriveFile): boolean;
15
+ /** Files/folders whose name starts with `_` are treated as internal/skipped. */
16
+ export declare function isInternal(file: DriveFile): boolean;
17
+ /** A keymap sheet is a spreadsheet named `_keymap` (internal, but special). */
18
+ export declare function isKeymapSheet(file: DriveFile): boolean;
19
+ export {};
20
+ //# sourceMappingURL=driveClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"driveClient.d.ts","sourceRoot":"","sources":["../../../src/lib/driveClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEpC,KAAK,UAAU,GAAG,UAAU,CAAC,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;AAE7D,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;CAClB;AAKD;;;GAGG;AACH,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,UAAU,EAChB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,SAAS,EAAE,CAAC,CAwBtB;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO,CAEtD;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO,CAEjD;AAED,gFAAgF;AAChF,wBAAgB,UAAU,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO,CAEnD;AAED,+EAA+E;AAC/E,wBAAgB,aAAa,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO,CAEtD"}
@@ -0,0 +1,23 @@
1
+ import type { LocaleKeyMap, TranslationMap } from "../types/index.js";
2
+ import { listFolderContents } from "./driveClient.js";
3
+ type AuthClient = Parameters<typeof listFolderContents>[0];
4
+ export interface FolderExtractorOptions {
5
+ auth: AuthClient;
6
+ folderId: string;
7
+ includeEmpty?: boolean;
8
+ userKeyMap?: LocaleKeyMap;
9
+ }
10
+ /**
11
+ * Recursively extracts translations from all spreadsheets inside a Drive folder.
12
+ *
13
+ * Naming conventions:
14
+ * - Files/folders starting with `_` are skipped (treated as internal).
15
+ * - A spreadsheet named exactly `_keymap` inside a folder provides locale
16
+ * key mappings that apply to all sheets in that folder.
17
+ * - Each spreadsheet's name is used as a namespace path component.
18
+ * - Sub-folder names become path components (e.g. folder `common` containing
19
+ * sheet `buttons` → namespace `common.buttons`).
20
+ */
21
+ export declare function extractFromFolder(options: FolderExtractorOptions): Promise<TranslationMap>;
22
+ export {};
23
+ //# sourceMappingURL=folderExtractor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"folderExtractor.d.ts","sourceRoot":"","sources":["../../../src/lib/folderExtractor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,EACL,kBAAkB,EAKnB,MAAM,kBAAkB,CAAC;AAQ1B,KAAK,UAAU,GAAG,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC;AAE3D,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,UAAU,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,UAAU,CAAC,EAAE,YAAY,CAAC;CAC3B;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,sBAAsB,GAC9B,OAAO,CAAC,cAAc,CAAC,CAWzB"}
@@ -0,0 +1,60 @@
1
+ import type { LocaleKeyMap, SheetGrid, TranslationMap, TranslationObject } from "../types/index.js";
2
+ /**
3
+ * Merges the default key map with any user-supplied overrides and an optional
4
+ * `_keymap` tab extracted from the spreadsheet itself.
5
+ *
6
+ * Priority (highest → lowest):
7
+ * 1. Spreadsheet `_keymap` tab
8
+ * 2. `localeKeyMap` option passed by the caller
9
+ * 3. Built-in `DEFAULT_LOCALE_KEY_MAP`
10
+ */
11
+ export declare function buildLocaleKeyMap(userKeyMap?: LocaleKeyMap, sheetKeyMap?: LocaleKeyMap): LocaleKeyMap;
12
+ /**
13
+ * Parses a `_keymap` tab (either from a dedicated sheet or from a tab named
14
+ * `_keymap` inside a spreadsheet).
15
+ *
16
+ * Expected layout:
17
+ * ```
18
+ * | locale code | fr | en | de |
19
+ * | header name | French| English | German |
20
+ * ```
21
+ * Row 0 = locale codes (output keys), Row 1+ = header name variants.
22
+ */
23
+ export declare function parseKeymapGrid(grid: SheetGrid): LocaleKeyMap;
24
+ /**
25
+ * Sets a value at a dotted path inside a nested object, creating intermediate
26
+ * objects as needed.
27
+ *
28
+ * @example
29
+ * setNestedValue({}, "actions.save", "Save")
30
+ * // → { actions: { save: "Save" } }
31
+ */
32
+ export declare function setNestedValue(obj: TranslationObject, dotPath: string, value: string): void;
33
+ export interface ParseGridOptions {
34
+ /** Resolved locale key map to translate header labels → locale codes. */
35
+ keyMap: LocaleKeyMap;
36
+ /**
37
+ * Namespace prefix to prepend to every key, separated by a dot.
38
+ * When provided, `"save"` becomes `"<namespace>.save"` in the output.
39
+ */
40
+ namespace?: string;
41
+ /** Zero-based column index to start reading from. Defaults to 0. */
42
+ startColumn?: number;
43
+ /** When true, empty translation values are written as "". Defaults to false. */
44
+ includeEmpty?: boolean;
45
+ }
46
+ /**
47
+ * Parses a single sheet grid and merges all found translations into `result`.
48
+ *
49
+ * Expected grid layout:
50
+ * ```
51
+ * | key (ignored) | EN | FR | DE |
52
+ * | actions.save | Save | Enreg. | Speich. |
53
+ * | actions.cancel | Cancel | Annuler | Abbruch |
54
+ * ```
55
+ *
56
+ * Column 0 is always the key column.
57
+ * Column 1 is the first language (index 1 in the header row).
58
+ */
59
+ export declare function parseGrid(grid: SheetGrid, result: TranslationMap, options: ParseGridOptions): void;
60
+ //# sourceMappingURL=parser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../../src/lib/parser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,SAAS,EAET,cAAc,EACd,iBAAiB,EAClB,MAAM,mBAAmB,CAAC;AAK3B;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAC/B,UAAU,CAAC,EAAE,YAAY,EACzB,WAAW,CAAC,EAAE,YAAY,GACzB,YAAY,CAMd;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,SAAS,GAAG,YAAY,CAc7D;AAID;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAC5B,GAAG,EAAE,iBAAiB,EACtB,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,GACZ,IAAI,CAaN;AAID,MAAM,WAAW,gBAAgB;IAC/B,yEAAyE;IACzE,MAAM,EAAE,YAAY,CAAC;IACrB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,oEAAoE;IACpE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gFAAgF;IAChF,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,SAAS,CACvB,IAAI,EAAE,SAAS,EACf,MAAM,EAAE,cAAc,EACtB,OAAO,EAAE,gBAAgB,GACxB,IAAI,CAoCN"}
@@ -0,0 +1,26 @@
1
+ import type { LocaleKeyMap, TranslationMap } from "../types/index.js";
2
+ import { getSpreadsheetTabs } from "./sheetsClient.js";
3
+ type AuthClient = Parameters<typeof getSpreadsheetTabs>[0];
4
+ export interface SheetExtractorOptions {
5
+ auth: AuthClient;
6
+ spreadsheetId: string;
7
+ /** When provided, only this specific tab (by numeric ID) is extracted. */
8
+ tabId?: number;
9
+ /** Zero-based column to start reading from. */
10
+ startColumn?: number;
11
+ includeEmpty?: boolean;
12
+ userKeyMap?: LocaleKeyMap;
13
+ }
14
+ /**
15
+ * Extracts translations from a single Google Spreadsheet.
16
+ *
17
+ * - If `tabId` is given → only that tab is parsed, keys are NOT namespaced.
18
+ * - If `tabId` is omitted → all non-internal tabs are parsed;
19
+ * each tab name becomes a namespace prefix (e.g. tab "actions" → key "actions.save").
20
+ *
21
+ * Tabs whose name starts with `_` are treated as internal and skipped,
22
+ * except for `_keymap` which is parsed to build a custom locale key map.
23
+ */
24
+ export declare function extractFromSheet(options: SheetExtractorOptions): Promise<TranslationMap>;
25
+ export {};
26
+ //# sourceMappingURL=sheetExtractor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sheetExtractor.d.ts","sourceRoot":"","sources":["../../../src/lib/sheetExtractor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,EAAE,kBAAkB,EAAc,MAAM,mBAAmB,CAAC;AAOnE,KAAK,UAAU,GAAG,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC;AAE3D,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,UAAU,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,0EAA0E;IAC1E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,+CAA+C;IAC/C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,UAAU,CAAC,EAAE,YAAY,CAAC;CAC3B;AAED;;;;;;;;;GASG;AACH,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,cAAc,CAAC,CAqDzB"}
@@ -0,0 +1,15 @@
1
+ import { google } from "googleapis";
2
+ import type { SheetGrid, SheetTab } from "../types/index.js";
3
+ type AuthClient = Parameters<typeof google.sheets>[0]["auth"];
4
+ /**
5
+ * Lists all tabs in a spreadsheet and returns their metadata.
6
+ */
7
+ export declare function getSpreadsheetTabs(auth: AuthClient, spreadsheetId: string): Promise<SheetTab[]>;
8
+ /**
9
+ * Fetches all cell values from a single tab of a spreadsheet.
10
+ *
11
+ * @param tabName - The display name of the tab. When omitted, the first tab is used.
12
+ */
13
+ export declare function getTabData(auth: AuthClient, spreadsheetId: string, tabName?: string): Promise<SheetGrid>;
14
+ export {};
15
+ //# sourceMappingURL=sheetsClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sheetsClient.d.ts","sourceRoot":"","sources":["../../../src/lib/sheetsClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7D,KAAK,UAAU,GAAG,UAAU,CAAC,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;AAE9D;;GAEG;AACH,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,UAAU,EAChB,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,QAAQ,EAAE,CAAC,CAWrB;AAED;;;;GAIG;AACH,wBAAsB,UAAU,CAC9B,IAAI,EAAE,UAAU,EAChB,aAAa,EAAE,MAAM,EACrB,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,SAAS,CAAC,CAcpB"}
@@ -0,0 +1,9 @@
1
+ import type { OutputFile, TranslationMap } from "../types/index.js";
2
+ /**
3
+ * Writes one JSON file per locale into `outputDir`.
4
+ * Creates the directory (and any parents) if it does not exist.
5
+ *
6
+ * @returns Metadata about each file that was written.
7
+ */
8
+ export declare function writeTranslationFiles(translations: TranslationMap, outputDir: string, indent?: number | string): Promise<OutputFile[]>;
9
+ //# sourceMappingURL=writer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"writer.d.ts","sourceRoot":"","sources":["../../../src/lib/writer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEpE;;;;;GAKG;AACH,wBAAsB,qBAAqB,CACzC,YAAY,EAAE,cAAc,EAC5B,SAAS,EAAE,MAAM,EACjB,MAAM,GAAE,MAAM,GAAG,MAAU,GAC1B,OAAO,CAAC,UAAU,EAAE,CAAC,CA0BvB"}
@@ -0,0 +1,153 @@
1
+ /**
2
+ * Contents of a Google Service Account JSON key file.
3
+ */
4
+ export interface ServiceAccountKey {
5
+ type: string;
6
+ project_id: string;
7
+ private_key_id: string;
8
+ private_key: string;
9
+ client_email: string;
10
+ client_id: string;
11
+ auth_uri: string;
12
+ token_uri: string;
13
+ auth_provider_x509_cert_url: string;
14
+ client_x509_cert_url: string;
15
+ }
16
+ /**
17
+ * A single row from a Google Sheet, as returned by the Sheets API.
18
+ * Each cell is a string (or undefined if the cell is empty).
19
+ */
20
+ export type SheetRow = string[];
21
+ /**
22
+ * Raw data for one tab/grid of a spreadsheet.
23
+ * First row = header row (key column + language columns).
24
+ * Subsequent rows = translation entries.
25
+ */
26
+ export type SheetGrid = SheetRow[];
27
+ /**
28
+ * Metadata about a single tab inside a spreadsheet.
29
+ */
30
+ export interface SheetTab {
31
+ /** Numeric ID of the tab inside the spreadsheet */
32
+ sheetId: number;
33
+ /** Display name of the tab */
34
+ title: string;
35
+ }
36
+ /**
37
+ * A nested JSON object representing one language's translations.
38
+ * Keys are strings; values are either nested objects or translation strings.
39
+ *
40
+ * @example
41
+ * {
42
+ * "actions": {
43
+ * "add_comment": "Add a comment"
44
+ * }
45
+ * }
46
+ */
47
+ export type TranslationObject = {
48
+ [key: string]: TranslationObject | string;
49
+ };
50
+ /**
51
+ * The full extraction result, keyed by locale code.
52
+ *
53
+ * @example
54
+ * {
55
+ * "en": { "actions": { "save": "Save" } },
56
+ * "fr": { "actions": { "save": "Enregistrer" } }
57
+ * }
58
+ */
59
+ export type TranslationMap = Record<string, TranslationObject>;
60
+ /**
61
+ * Maps raw column header values (as written in the sheet) to BCP-47
62
+ * locale codes used as output file names.
63
+ *
64
+ * @example
65
+ * { "French": "fr", "EN": "en", "繁體中文": "zh-TW" }
66
+ */
67
+ export type LocaleKeyMap = Record<string, string>;
68
+ /**
69
+ * Options for a single-spreadsheet extraction (sheet mode).
70
+ */
71
+ export interface SheetModeOptions {
72
+ mode: "sheet";
73
+ /** Google Spreadsheet ID (from its URL) */
74
+ spreadsheetId: string;
75
+ /**
76
+ * Numeric tab/grid ID to extract. When omitted, all tabs whose name
77
+ * does not start with `_` are extracted and merged by namespace.
78
+ */
79
+ tabId?: number;
80
+ /**
81
+ * Zero-based column index to start reading from.
82
+ * Useful when the sheet has leading columns you want to skip (e.g. comments).
83
+ * Defaults to 0.
84
+ */
85
+ startColumn?: number;
86
+ }
87
+ /**
88
+ * Options for a Google Drive folder extraction (folder mode).
89
+ * Every spreadsheet found in the folder (non-recursively) is extracted.
90
+ * Sub-folders are traversed recursively.
91
+ */
92
+ export interface FolderModeOptions {
93
+ mode: "folder";
94
+ /** Google Drive folder ID (from its URL) */
95
+ folderId: string;
96
+ }
97
+ /**
98
+ * Union of the two supported extraction modes.
99
+ */
100
+ export type ExtractionMode = SheetModeOptions | FolderModeOptions;
101
+ /**
102
+ * Full configuration object accepted by the `extract()` programmatic API.
103
+ */
104
+ export interface ExtractOptions {
105
+ /** Authentication: path to a Service Account JSON file, or the parsed object */
106
+ serviceAccountKey: string | ServiceAccountKey;
107
+ /** Where and what to extract */
108
+ source: ExtractionMode;
109
+ /**
110
+ * Directory where output JSON files will be written.
111
+ * Created automatically if it does not exist.
112
+ * @default "./i18n"
113
+ */
114
+ outputDir?: string;
115
+ /**
116
+ * Custom mapping from sheet column headers to locale codes.
117
+ * Merged on top of the built-in default key map.
118
+ * Entries in the spreadsheet's `_keymap` tab always take highest priority.
119
+ */
120
+ localeKeyMap?: LocaleKeyMap;
121
+ /**
122
+ * When true, keys with empty translation values are included in the output
123
+ * with an empty string value. By default they are omitted.
124
+ * @default false
125
+ */
126
+ includeEmpty?: boolean;
127
+ /**
128
+ * Output JSON indentation. Accepts a number of spaces or a string (e.g. "\t").
129
+ * @default 2
130
+ */
131
+ indent?: number | string;
132
+ }
133
+ /**
134
+ * Information about a single written output file.
135
+ */
136
+ export interface OutputFile {
137
+ /** Locale code, e.g. "en" or "zh-TW" */
138
+ locale: string;
139
+ /** Absolute path to the written file */
140
+ path: string;
141
+ /** Number of top-level namespace keys in the file */
142
+ keyCount: number;
143
+ }
144
+ /**
145
+ * Result returned by the `extract()` function.
146
+ */
147
+ export interface ExtractResult {
148
+ /** List of files that were written */
149
+ files: OutputFile[];
150
+ /** Total wall-clock time in milliseconds */
151
+ durationMs: number;
152
+ }
153
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,2BAA2B,EAAE,MAAM,CAAC;IACpC,oBAAoB,EAAE,MAAM,CAAC;CAC9B;AAID;;;GAGG;AACH,MAAM,MAAM,QAAQ,GAAG,MAAM,EAAE,CAAC;AAEhC;;;;GAIG;AACH,MAAM,MAAM,SAAS,GAAG,QAAQ,EAAE,CAAC;AAEnC;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,mDAAmD;IACnD,OAAO,EAAE,MAAM,CAAC;IAChB,8BAA8B;IAC9B,KAAK,EAAE,MAAM,CAAC;CACf;AAID;;;;;;;;;;GAUG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,CAAC,GAAG,EAAE,MAAM,GAAG,iBAAiB,GAAG,MAAM,CAAC;CAC3C,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;AAI/D;;;;;;GAMG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAIlD;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,OAAO,CAAC;IACd,2CAA2C;IAC3C,aAAa,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,QAAQ,CAAC;IACf,4CAA4C;IAC5C,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,gBAAgB,GAAG,iBAAiB,CAAC;AAElE;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,gFAAgF;IAChF,iBAAiB,EAAE,MAAM,GAAG,iBAAiB,CAAC;IAE9C,gCAAgC;IAChC,MAAM,EAAE,cAAc,CAAC;IAEvB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;;OAIG;IACH,YAAY,CAAC,EAAE,YAAY,CAAC;IAE5B;;;;OAIG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CAC1B;AAID;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,wCAAwC;IACxC,MAAM,EAAE,MAAM,CAAC;IACf,wCAAwC;IACxC,IAAI,EAAE,MAAM,CAAC;IACb,qDAAqD;IACrD,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,sCAAsC;IACtC,KAAK,EAAE,UAAU,EAAE,CAAC;IACpB,4CAA4C;IAC5C,UAAU,EAAE,MAAM,CAAC;CACpB"}
package/package.json ADDED
@@ -0,0 +1,62 @@
1
+ {
2
+ "name": "gsheets-i18n",
3
+ "version": "1.0.0",
4
+ "description": "Generate i18n JSON files from a Google Spreadsheet",
5
+ "author": "Jv Durieu",
6
+ "license": "MIT",
7
+ "keywords": [
8
+ "i18n",
9
+ "i18next",
10
+ "google-sheets",
11
+ "google-spreadsheet",
12
+ "localization",
13
+ "translation",
14
+ "cli"
15
+ ],
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "https://github.com/Najtal/gsheets-i18n"
19
+ },
20
+ "bugs": {
21
+ "url": "https://github.com/Najtal/gsheets-i18n/issues"
22
+ },
23
+ "type": "module",
24
+ "main": "./dist/cjs/index.js",
25
+ "module": "./dist/esm/index.js",
26
+ "types": "./dist/types/index.d.ts",
27
+ "exports": {
28
+ ".": {
29
+ "import": "./dist/esm/index.js",
30
+ "require": "./dist/cjs/index.js",
31
+ "types": "./dist/types/index.d.ts"
32
+ }
33
+ },
34
+ "bin": {
35
+ "sheets-i18n": "./dist/esm/cli/index.js"
36
+ },
37
+ "files": [
38
+ "dist",
39
+ "README.md",
40
+ "LICENSE"
41
+ ],
42
+ "scripts": {
43
+ "build": "npm run build:esm && npm run build:cjs && npm run build:types",
44
+ "build:esm": "tsc -p tsconfig.esm.json",
45
+ "build:cjs": "tsc -p tsconfig.cjs.json",
46
+ "build:types": "tsc -p tsconfig.types.json",
47
+ "dev": "tsc -p tsconfig.esm.json --watch",
48
+ "clean": "rm -rf dist",
49
+ "prepublishOnly": "npm run clean && npm run build"
50
+ },
51
+ "engines": {
52
+ "node": ">=18.0.0"
53
+ },
54
+ "dependencies": {
55
+ "commander": "^12.0.0",
56
+ "googleapis": "^144.0.0"
57
+ },
58
+ "devDependencies": {
59
+ "@types/node": "^22.20.0",
60
+ "typescript": "^5.5.0"
61
+ }
62
+ }