Skip to content
This repository was archived by the owner on Nov 14, 2025. It is now read-only.

Commit 015d076

Browse files
authored
Fix english-please for multi-language content (#327)
1 parent d0c6df1 commit 015d076

File tree

2 files changed

+34
-24
lines changed

2 files changed

+34
-24
lines changed

english-please/EnglishPlease.js

Lines changed: 16 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

english-please/EnglishPlease.ts

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)