mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-18 13:56:25 +02:00
Make my translator Case-Insensitive
This commit is contained in:
@@ -2,7 +2,7 @@ module.exports.wordTrans = (text, words) => {
|
|||||||
text = text.split(' ');
|
text = text.split(' ');
|
||||||
let translation = [];
|
let translation = [];
|
||||||
for (let i = 0; i < text.length; i++) {
|
for (let i = 0; i < text.length; i++) {
|
||||||
const word = text[i];
|
const word = text[i].toLowerCase();
|
||||||
const wordPuncStrip = word.replace(/[.,?!-]/g, '');
|
const wordPuncStrip = word.replace(/[.,?!-]/g, '');
|
||||||
if (words[wordPuncStrip]) {
|
if (words[wordPuncStrip]) {
|
||||||
const reg = new RegExp(wordPuncStrip, 'gi');
|
const reg = new RegExp(wordPuncStrip, 'gi');
|
||||||
@@ -19,7 +19,7 @@ module.exports.letterTrans = (text, letters) => {
|
|||||||
text = text.split('');
|
text = text.split('');
|
||||||
let translation = [];
|
let translation = [];
|
||||||
for (let i = 0; i < text.length; i++) {
|
for (let i = 0; i < text.length; i++) {
|
||||||
const letter = text[i];
|
const letter = text[i].toLowerCase();
|
||||||
if (letters[letter]) {
|
if (letters[letter]) {
|
||||||
const reg = new RegExp(letter, 'gi');
|
const reg = new RegExp(letter, 'gi');
|
||||||
translation.push(letter.replace(reg, letters[letter]));
|
translation.push(letter.replace(reg, letters[letter]));
|
||||||
|
|||||||
Reference in New Issue
Block a user