mirror of
https://github.com/kolbytn/mindcraft.git
synced 2025-08-01 04:45:40 +02:00
Merge pull request #273 from kolbytn/no-translator
dont translate when in english
This commit is contained in:
commit
27fad707bf
1 changed files with 7 additions and 9 deletions
|
@ -1,18 +1,14 @@
|
||||||
import translate from 'google-translate-api-x';
|
import translate from 'google-translate-api-x';
|
||||||
import settings from '../../settings.js';
|
import settings from '../../settings.js';
|
||||||
|
|
||||||
const preferred_lang = settings.language;
|
const preferred_lang = String(settings.language).toLowerCase();
|
||||||
|
|
||||||
export async function handleTranslation(message) {
|
export async function handleTranslation(message) {
|
||||||
|
if (preferred_lang === 'en' || preferred_lang === 'english')
|
||||||
|
return message;
|
||||||
try {
|
try {
|
||||||
if (preferred_lang.toLowerCase() === 'en' || preferred_lang.toLowerCase() === 'english') {
|
const translation = await translate(message, { to: preferred_lang });
|
||||||
return message;
|
return translation.text || message;
|
||||||
} else {
|
|
||||||
const lang = String(preferred_lang);
|
|
||||||
|
|
||||||
const translation = await translate(message, { to: lang });
|
|
||||||
return translation.text || message;
|
|
||||||
}
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error translating message:', error);
|
console.error('Error translating message:', error);
|
||||||
return message;
|
return message;
|
||||||
|
@ -20,6 +16,8 @@ export async function handleTranslation(message) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function handleEnglishTranslation(message) {
|
export async function handleEnglishTranslation(message) {
|
||||||
|
if (preferred_lang === 'en' || preferred_lang === 'english')
|
||||||
|
return message;
|
||||||
try {
|
try {
|
||||||
const translation = await translate(message, { to: 'english' });
|
const translation = await translate(message, { to: 'english' });
|
||||||
return translation.text || message;
|
return translation.text || message;
|
||||||
|
|
Loading…
Add table
Reference in a new issue