File tree Expand file tree Collapse file tree 3 files changed +36
-6
lines changed
packages/new-compiler/src Expand file tree Collapse file tree 3 files changed +36
-6
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " @lingo.dev/compiler " : patch
3+ ---
4+
5+ Improve translation error logging by writing detailed errors to .lingo/translation-server.log
Original file line number Diff line number Diff line change @@ -331,7 +331,7 @@ export class TranslationServer {
331331 */
332332 async translateAll ( locale : LocaleCode ) : Promise < {
333333 translations : Record < string , string > ;
334- errors : Array < { hash : string ; error : string } > ;
334+ errors : Array < { hash : string ; sourceText : string ; error : string } > ;
335335 } > {
336336 if ( ! this . translationService ) {
337337 throw new Error ( "Translation server not initialized" ) ;
@@ -368,6 +368,27 @@ export class TranslationServer {
368368 allHashes ,
369369 ) ;
370370
371+ // Log detailed error information to server log file
372+ if ( result . errors . length > 0 ) {
373+ this . logger . error (
374+ `${ result . errors . length } translation error(s) for ${ locale } :` ,
375+ ) ;
376+ for ( const err of result . errors ) {
377+ const prefix = ` [${ locale } ]` ;
378+ if ( err . hash === "all" ) {
379+ this . logger . error ( `${ prefix } ${ err . error } ` ) ;
380+ continue ;
381+ }
382+ const source =
383+ err . sourceText . length > 200
384+ ? err . sourceText . slice ( 0 , 200 ) + "..."
385+ : err . sourceText ;
386+ this . logger . error (
387+ `${ prefix } hash=${ err . hash } source="${ source } " error="${ err . error } "` ,
388+ ) ;
389+ }
390+ }
391+
371392 // Broadcast batch complete event
372393 const duration = Date . now ( ) - startTime ;
373394 this . broadcast (
Original file line number Diff line number Diff line change @@ -259,7 +259,14 @@ Set the required API keys for real translations.`);
259259 // Merge translated texts with overridden translations
260260 newTranslations = { ...overriddenTranslations , ...translatedTexts } ;
261261 } catch ( error ) {
262- this . logger . error ( `Translation failed:` , error ) ;
262+ const errorMessage =
263+ error instanceof Error ? error . message : String ( error ) ;
264+ this . logger . error (
265+ `Translation failed for locale "${ locale } ": ${ errorMessage } ` ,
266+ ) ;
267+ if ( error instanceof Error && error . stack ) {
268+ this . logger . debug ( `Stack trace: ${ error . stack } ` ) ;
269+ }
263270
264271 return {
265272 translations : this . pickTranslations (
@@ -270,10 +277,7 @@ Set the required API keys for real translations.`);
270277 {
271278 hash : "all" ,
272279 sourceText : "all" ,
273- error :
274- error instanceof Error
275- ? error . message
276- : "Unknown translation error" ,
280+ error : errorMessage ,
277281 } ,
278282 ] ,
279283 stats : {
You can’t perform that action at this time.
0 commit comments