Skip to content

Commit

Permalink
feat(helpers): add lang check
Browse files Browse the repository at this point in the history
  • Loading branch information
crimx committed Dec 4, 2018
1 parent 2bc0dff commit 5375f67
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/_helpers/lang-check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ export const testJapanese = /[\u3041-\u3096\u30A0-\u30FF]/
/** Korean Hangul, no Chinese */
export const testKorean = /[\u3131-\u4dff\u9fa6-\uD79D]/

/** French, no English àâäèéêëîïôœùûüÿç */
export const testFrench = /[\u00e0\u00e2\u00e4\u00e8\u00e9\u00ea\u00eb\u00ee\u00ef\u00f4\u0153\u00f9\u00fb\u00fc\u00ff\u00e7]/i

/** Deutsch, no English äöüÄÖÜß */
export const testDeutsch = /\u00E4\u00F6\u00FC\u00C4\u00D6\u00DC\u00df/i

/** Spanish, no English áéíóúñü¡¿ */
export const testSpanish = /\u00e1\u00e9\u00ed\u00f3\u00fa\u00f1\u00fc\u00a1\u00bf/i

/** Languages excpet Chinese and English */
export const testerMinor = /[^\u4e00-\u9fa5a-zA-Z0-9\s\/\[\]\{\}\$\^\*\+\|\?\.\-~!@#%&()_='";:><,。?!,、;:“”﹃﹄「」﹁﹂‘’『』()—[]〔〕【】…-~·‧《》〈〉﹏_]/

Expand All @@ -30,6 +39,21 @@ export function isContainKorean (text: string): boolean {
return testKorean.test(text)
}

/** French, no English àâäèéêëîïôœùûüÿç */
export function isContainFrench (text: string): boolean {
return testFrench.test(text)
}

/** Deutsch, no English äöüÄÖÜß */
export function isContainDeutsch (text: string): boolean {
return testDeutsch.test(text)
}

/** Spanish, no English áéíóúñü¡¿ */
export function isContainSpanish (text: string): boolean {
return testSpanish.test(text)
}

/** Languages excpet Chinese and English */
export function isContainMinor (text: string): boolean {
return testerMinor.test(text)
Expand Down

0 comments on commit 5375f67

Please sign in to comment.