Skip to content
Permalink
Browse files
tweak: do not add en label when issue contains over 5 Chinese charact…
…ers.
  • Loading branch information
plainheart committed Nov 23, 2020
1 parent 6667085 commit 5510b947678e0ded614ff7e798c2a6144911869d
Showing 1 changed file with 8 additions and 1 deletion.
@@ -1,6 +1,9 @@
const text = require('./text');
const { isCommitter } = require('./coreCommitters');

const REG_CHN_CHAR = /[\u4e00-\u9fa5]/g;
const MAX_CHN_CHAR_COUNT = 5;

class Issue {
constructor(context) {
this.context = context;
@@ -57,14 +60,18 @@ class Issue {
this.addLabels.push(this.issueType);

const isInEnglish = this._contain('This issue is in English');
if (isInEnglish) {
if (isInEnglish && !this._isMainlyUsingChinese()) {
this.addLabels.push('en');
}
}

_contain(txt) {
return this.body.indexOf(txt) > -1;
}

_isMainlyUsingChinese() {
return this.body.match(REG_CHN_CHAR).length > MAX_CHN_CHAR_COUNT;
}
}

module.exports = Issue;

0 comments on commit 5510b94

Please sign in to comment.