sheets-translate-to-json
Version:
A Node.js library that facilitates the retrieval and conversion of previously translated Google Sheets spreadsheets into structured JSON files, optimizing the management of localized resources.
48 lines (46 loc) • 1.37 kB
text/typescript
interface NestedObject {
[key: string]: string | NestedObject | undefined;
}
interface SheetData {
[key: string]: NestedObject;
}
type SyncStrategy = 'local' | 'remote' | 'merge';
interface SyncOptions {
strategy?: SyncStrategy;
sheetName?: string;
createSheet?: boolean;
}
interface SyncResult {
added: {
local: number;
remote: number;
};
updated: {
local: number;
remote: number;
};
languages: string[];
}
declare class SheetManager {
private doc;
private jwt;
constructor(privateKey: string, clientEmail: string, sheetId: string);
init(userPath: string, sheetNames?: string[]): Promise<void>;
read(sheetPosition?: number): Promise<SheetData>;
readByName(sheetName: string): Promise<SheetData>;
readAllSheets(): Promise<{
[sheetName: string]: SheetData;
}>;
private processSheet;
private setNestedValue;
private mergeNestedObjects;
write(data: SheetData, directoryPath: string): void;
listSheets(): Promise<string[]>;
readLocal(directoryPath: string): SheetData;
push(directoryPath: string, sheetName?: string): Promise<void>;
sync(directoryPath: string, options?: SyncOptions): Promise<SyncResult>;
private flattenNestedObject;
private flattenSheetData;
private flattenAllLanguages;
}
export { SheetManager };