You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
14 lines
317 B
14 lines
317 B
export enum Languages { |
|
EN = "en", |
|
RU = "ru", |
|
} |
|
|
|
export const detectLang = (text: string): Languages => { |
|
let lang = Languages.EN |
|
const ruCount = text.match(/([а-я])/g)?.length || 0 |
|
const enCount = text.match(/([a-z])/g)?.length || 0 |
|
if (ruCount > enCount) { |
|
lang = Languages.RU |
|
} |
|
return lang |
|
}
|
|
|