Skip to content

Commit

Permalink
Merge pull request #101 from translate-tools/100-google-translator-is…
Browse files Browse the repository at this point in the history
…-not-support-chinese-with-no-postfix

Google translator is not support chinese with no postfix
  • Loading branch information
vitonsky authored Jun 16, 2024
2 parents da45821 + 41a08fe commit e2f0612
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/translators/GoogleTranslator/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const supportedLanguages = [
'si', 'sk', 'sl', 'sm', 'sn', 'so', 'sq', 'sr', 'st', 'su',
'sv', 'sw', 'ta', 'te', 'tg', 'th', 'ti', 'tk', 'tl', 'tr',
'ts', 'tt', 'ug', 'uk', 'ur', 'uz', 'vi', 'xh', 'yi', 'yo',
'zh-CN', 'zh-TW', 'zu'
'zh', 'zh-CN', 'zh-TW', 'zu'
];
// eslint-enable

Expand Down
23 changes: 23 additions & 0 deletions src/translators/__tests__/translators.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,29 @@ translatorsForTest.forEach(({ translator: translatorClass, options }) => {
});
});

const isNeedCheckToZh = [
'GoogleTranslator',
'YandexTranslator',
'DeepLTranslator',
].some((name) => translatorName.startsWith(name));
if (isNeedCheckToZh) {
test(`Method "getSupportedLanguages" supports chinese language`, () => {
const languages = translatorClass.getSupportedLanguages();
expect(languages).toContain('zh');
});

test(`Method "translate" supports chinese language`, async () => {
const translator = new translatorClass(translatorOptions);
await translator
.translate('Hello world', 'en', 'zh')
.then((translation) => {
expect(typeof translation).toBe('string');
expect(translation).toContain('世界');
expect(isStringStartFromLetter(translation)).toBeTruthy();
});
});
}

test(`Translate one text with method "translate"`, async () => {
const translator = new translatorClass(translatorOptions);
await translator.translate('Hello world', 'en', 'ru').then((translation) => {
Expand Down

0 comments on commit e2f0612

Please sign in to comment.