MCPcopy
hub / github.com/lingodotdev/lingo.dev / triggerRetranslation

Function triggerRetranslation

packages/cli/src/cli/cmd/run/watch.ts:157–195  Ā·  view source on GitHub ↗
(state: WatchState, ctx: CmdRunContext)

Source from the content-addressed store, hash-verified

155}
156
157async function triggerRetranslation(state: WatchState, ctx: CmdRunContext) {
158 if (state.isRunning) return;
159
160 state.isRunning = true;
161
162 try {
163 const changedFiles = Array.from(state.pendingChanges);
164 state.pendingChanges.clear();
165
166 console.log(chalk.hex(colors.green)("\nšŸ”„ Triggering retranslation..."));
167 console.log(chalk.dim(`Changed files: ${changedFiles.join(", ")}`));
168 console.log("");
169
170 // Create a new context for this run (preserve original flags but reset tasks/results)
171 const runCtx: CmdRunContext = {
172 ...ctx,
173 tasks: [],
174 results: new Map(),
175 };
176
177 // Re-run the translation pipeline
178 await plan(runCtx);
179
180 if (runCtx.tasks.length === 0) {
181 console.log(chalk.dim("✨ No translation tasks needed"));
182 } else {
183 await execute(runCtx);
184 await renderSummary(runCtx.results);
185 }
186
187 console.log(chalk.hex(colors.green)("āœ… Retranslation completed"));
188 console.log(chalk.dim("šŸ‘€ Continuing to watch for changes...\n"));
189 } catch (error: any) {
190 console.error(chalk.red(`āŒ Retranslation failed: ${error.message}`));
191 console.log(chalk.dim("šŸ‘€ Continuing to watch for changes...\n"));
192 } finally {
193 state.isRunning = false;
194 }
195}

Callers 1

handleFileChangeFunction Ā· 0.85

Calls 6

renderSummaryFunction Ā· 0.90
planFunction Ā· 0.85
executeFunction Ā· 0.85
logMethod Ā· 0.80
errorMethod Ā· 0.80
clearMethod Ā· 0.65

Tested by

no test coverage detected