import type { GoogleSpreadsheet } from "google-spreadsheet"; import type { TranslationData } from "../types"; /** * Updates the Google Spreadsheet with new keys from local data. * * When autoTranslate is enabled: * - For each new key added to the spreadsheet, the system checks which languages have translations * - For languages missing translations, it automatically adds Google Translate formulas * - The formula extracts the language prefix from the header cell (e.g. "tr-TR" → "tr") because * GOOGLETRANSLATE only accepts ISO 639-1 codes for most languages * - The formula format is: * =GOOGLETRANSLATE(INDIRECT(sourceColumn&ROW());LOWER(IFERROR(LEFT($sourceColumn$1,FIND("-",$sourceColumn$1)-1),$sourceColumn$1));LOWER(IFERROR(LEFT(targetColumn$1,FIND("-",targetColumn$1)-1),targetColumn$1))) * - This dynamic formula uses cell references for language codes and automatically adapts to the correct row * - For **existing** keys the same logic applies: empty cells in other language columns receive a * formula; cells that already contain a translation are only overwritten when `override` is true. * * A proactive inter-request delay of `waitSeconds` seconds is inserted between each * individual row save and between each addRows chunk to avoid exceeding Google's * "Write requests per minute per user" quota before a 429 is even returned. * * If a sheet named `sheetTitle` does not yet exist in the document and `localeMapping` is * non-empty, the sheet is **created automatically** with "key" as the first column followed by * the original locale-header names from `localeMapping`. This ensures that new feature sheets * (e.g. "ui") are bootstrapped on the first sync without requiring manual spreadsheet setup. * * Example: * If a new key "welcome" has an English translation in column B but no German translation in column C, * and autoTranslate is enabled, the system will add a formula that translates from English ("en") * to the language code extracted from the German column header to the German column. * * @param doc - The Google Spreadsheet instance * @param changes - Object containing new keys to add to the spreadsheet * @param waitSeconds - Seconds to wait between consecutive write API calls (throttle) and as the * base back-off delay when retrying rate-limited calls (HTTP 429/503). Must be ≥ 1. * @param autoTranslate - Whether to add Google Translate formulas for missing translations (default: false) * @param localeMapping - Mapping from normalized locale codes to original spreadsheet headers * @param override - When true AND autoTranslate is true, existing translations in other language * columns are overwritten with GOOGLETRANSLATE formulas. When false (default) only empty cells * receive a formula. * @returns Promise that resolves when the update is complete */ export declare function updateSpreadsheetWithLocalChanges(doc: GoogleSpreadsheet, changes: TranslationData, waitSeconds: number, autoTranslate?: boolean, localeMapping?: Record, override?: boolean): Promise; //# sourceMappingURL=spreadsheetUpdater.d.ts.map