@@ -112,38 +112,43 @@ export class LanguageSpecificLabeler {
112112
113113 const language = ( await this . detectLanguage ( translationChunk ) ) ?. toLowerCase ( ) ;
114114 safeLog ( 'Detected language:' , language ?? 'undefined' ) ;
115- if ( ! language || language === 'en' ) {
115+ if ( ! language ) {
116116 const languagelabel = issue . labels . find ( ( label ) =>
117117 label . startsWith ( this . translatorRequestedLabelPrefix ) ,
118118 ) ;
119119 if ( languagelabel ) await this . issue . removeLabel ( languagelabel ) ;
120120 await this . issue . removeLabel ( this . englishPleaseLabel ) ;
121121 await this . issue . removeLabel ( this . needsMoreInfoLabel ) ;
122122 } else if ( language ) {
123+ // check again, another bot may have commented in the mean time.
124+ for await ( const page of this . issue . getComments ( ) ) {
125+ for ( const comment of page ) {
126+ if ( comment . body . includes ( '<!-- translation_requested_comment -->' ) ) {
127+ return ;
128+ }
129+ }
130+ }
131+
132+ if ( this . needsMoreInfoLabel ) await this . issue . addLabel ( this . needsMoreInfoLabel ) ;
133+ const englishComment = knownTranslations [ 'en' ] ;
134+ if ( language === 'en' ) {
135+ // Contents could be a mix of en and other languages, no need to translate but leave a comment for the user
136+ await this . issue . postComment ( `${ englishComment } \n<!-- translation_requested_comment -->` ) ;
137+ return ;
138+ }
139+
123140 const label = this . translatorRequestedLabelPrefix + commonNames [ language ] ;
124141 if ( ! ( await this . issue . repoHasLabel ( label ) ) ) {
125142 safeLog ( 'Globally creating label ' + label ) ;
126143 await this . issue . createLabel ( label , this . translatorRequestedLabelColor , '' ) ;
127144 }
128145 await this . issue . addLabel ( label ) ;
129- if ( this . needsMoreInfoLabel ) await this . issue . addLabel ( this . needsMoreInfoLabel ) ;
130146
131147 const targetLanguageComment =
132148 knownTranslations [ language ] ??
133149 ( await this . translate ( baseString , language ) ) ??
134150 'ERR_TRANSLATION_FAILED' ;
135151
136- const englishComment = knownTranslations [ 'en' ] ;
137-
138- // check again, another bot may have commented in the mean time.
139- for await ( const page of this . issue . getComments ( ) ) {
140- for ( const comment of page ) {
141- if ( comment . body . includes ( '<!-- translation_requested_comment -->' ) ) {
142- return ;
143- }
144- }
145- }
146-
147152 await this . issue . postComment (
148153 `${ targetLanguageComment } \n\n---\n${ englishComment } \n<!-- translation_requested_comment -->` ,
149154 ) ;
0 commit comments