diff --git a/package.json b/package.json index 983ef10..a13dddc 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@kdwnil/translator-utils", "private": true, - "version": "0.0.2-alpha.26", + "version": "0.0.2-alpha.27", "description": "translate utils", "homepage": "https://github.com/BANKA2017/translator-utils", "bugs": { @@ -20,6 +20,7 @@ "default": "./dist/esm/index.js" } }, + "./lib/*": "./lib/*", "./package.json": "./package.json" }, "type": "module", diff --git a/scripts/language_list_types_builder.mjs b/scripts/language_list_types_builder.mjs index cbf9aa0..f0d8689 100644 --- a/scripts/language_list_types_builder.mjs +++ b/scripts/language_list_types_builder.mjs @@ -10,7 +10,8 @@ jsContent += `export type GOOGLE_LIST = ${Object.entries(google) .join('|')}\n` jsContent += `export const GOOGLE_LANGUAGE: TargetFilter['google'][] = [${Object.entries(google) .map((lang) => "'" + lang[0] + "'") - .join(',')}]\n\n` + .join(',')}]\n` +jsContent += `export const GOOGLE_LANGUAGE_OBJECT: { [p in GOOGLE_LIST]: string } = ${JSON.stringify(google)}\n` // microsoft content/type/tts // JSON.stringify(Object.fromEntries([...tta_srcsl.querySelectorAll('option[aria-label]')].map(x => [x.value.toLowerCase(), x.innerText]).sort((a, b) => a[0] > b[0] ? 1 : -1))) @@ -21,11 +22,12 @@ jsContent += `export type BING_LIST = ${Object.entries(microsoft) jsContent += `export const BING_LANGUAGE: TargetFilter['microsoft'][] = [${Object.entries(microsoft) .map((lang) => "'" + lang[0] + "'") .join(',')}]\n` +jsContent += `export const BING_LANGUAGE_OBJECT: { [p in BING_LIST]: string } = ${JSON.stringify(microsoft)}\n` const microsoft_tts = JSON.parse(readFileSync('../assets/target/microsoft_tts.json').toString()) jsContent += `export type BING_TTS_LIST = ${microsoft_tts.map((msttsItem) => "'" + msttsItem.code + "'").join('|')}\n` -jsContent += `export const MICROSOFT_TTS_LIST: { code: BING_TTS_LIST; language: string; gender: 'Male' | 'Female'; model: string }[] = ${JSON.stringify(microsoft_tts)}\n\n` +jsContent += `export const MICROSOFT_TTS_LIST: { code: BING_TTS_LIST; language: string; gender: 'Male' | 'Female'; model: string }[] = ${JSON.stringify(microsoft_tts)}\n` // yandex content/type // JSON.stringify(Object.fromEntries([...document.querySelectorAll('.langs-item.langs-item_cell.langs-item_hasLetterSpace')].map(x => [x.dataset.value.toLowerCase(), x.innerText.includes('\n') ? x.innerText.split('\n')[1].trim() : x.innerText.trim()]).sort((a, b) => a[0] > b[0] ? 1 : -1))) @@ -35,7 +37,8 @@ jsContent += `export type YANDEX_LIST = ${Object.entries(yandex) .join('|')}\n` jsContent += `export const YANDEX_LANGUAGE: TargetFilter['yandex'][] = [${Object.entries(yandex) .map((lang) => "'" + lang[0] + "'") - .join(',')}]\n\n` + .join(',')}]\n` +jsContent += `export const YANDEX_LANGUAGE_OBJECT: { [p in YANDEX_LIST]: string } = ${JSON.stringify(yandex)}\n` // deepl content/type const deepl = JSON.parse(readFileSync('../assets/target/deepl.json').toString()) @@ -44,7 +47,8 @@ jsContent += `export type DEEPL_LIST = ${Object.entries(deepl) .join('|')}\n` jsContent += `export const DEEPL_LANGUAGE: TargetFilter['deepl'][] = [${Object.entries(deepl) .map((lang) => "'" + lang[0] + "'") - .join(',')}]\n\n` + .join(',')}]\n` +jsContent += `export const DEEPL_LANGUAGE_OBJECT: { [p in DEEPL_LIST]: string } = ${JSON.stringify(deepl)}\n` // baidu content/type/tts const baidu = JSON.parse(readFileSync('../assets/target/baidu.json').toString()) @@ -54,9 +58,10 @@ jsContent += `export type BAIDU_LIST = ${Object.entries(baidu) jsContent += `export const BAIDU_LANGUAGE: TargetFilter['baidu'][] = [${Object.entries(baidu) .map((lang) => "'" + lang[0] + "'") .join(',')}]\n` +jsContent += `export const BAIDU_LANGUAGE_OBJECT: { [p in BAIDU_LIST]: string } = ${JSON.stringify(baidu)}\n` const baidu_tts = JSON.parse(readFileSync('../assets/target/baidu_tts.json').toString()) -jsContent += `export type BAIDU_TTS_LIST = ${baidu_tts.map((lang) => "'" + lang + "'").join('|')}\n\n` +jsContent += `export type BAIDU_TTS_LIST = ${baidu_tts.map((lang) => "'" + lang + "'").join('|')}\n` // sogou const sogou = JSON.parse(readFileSync('../assets/target/sogou.json').toString()) @@ -66,6 +71,7 @@ jsContent += `export type SOGOU_LIST = ${Object.entries(sogou) jsContent += `export const SOGOU_LANGUAGE: TargetFilter['sogou'][] = [${Object.entries(sogou) .map((lang) => "'" + lang[0] + "'") .join(',')}]\n` +jsContent += `export const SOGOU_LANGUAGE_OBJECT: { [p in SOGOU_LIST]: string } = ${JSON.stringify(sogou)}\n` jsContent += `export type SOGOU_TTS_LIST = Exclude\n` diff --git a/src/index.ts b/src/index.ts index 9a02b7e..c40b88f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,6 +1,6 @@ import { BaiduLanguagePredict, BaiduTranslator, GetBaiduTranslatorToken, BaiduTTS } from './source/baidu.js' import { DeepL } from './source/deepl.js' -import { GoogleTranslate, GoogleBrowserTranslate, GoogleTTS } from './source/google.js' +import { GoogleTranslate, GoogleBrowserTranslate, GoogleTTS, GoogleTranslateTk } from './source/google.js' import { MicrosoftTranslator, MicrosoftBrowserTranslator, GetMicrosoftBrowserTranslatorAuth, GetMicrosoftTranslatorToken, MicrosoftBrowserPredict, MicrosoftTTS } from './source/microsoft.js' import { SogouBrowserTranslator, SogouTTS } from './source/sogou.js' import { YandexDetect, YandexTranslator, YandexBrowserTranslator } from './source/yandex.js' @@ -62,6 +62,7 @@ export { YandexBrowserTranslator } export { GetBaiduTranslatorToken, GetMicrosoftBrowserTranslatorAuth, GetMicrosoftTranslatorToken } +export { GoogleTranslateTk } export { IsChs, IsCht } export { GoogleTTS, MicrosoftTTS, BaiduTTS, SogouTTS } export default Translator diff --git a/src/language.ts b/src/language.ts index eab1947..e494bcb 100644 --- a/src/language.ts +++ b/src/language.ts @@ -1,23 +1,23 @@ import type { TargetFilter } from 'types.js' - export type GOOGLE_LIST = 'af'|'ak'|'am'|'ar'|'as'|'ay'|'az'|'be'|'bg'|'bho'|'bm'|'bn'|'bs'|'ca'|'ceb'|'ckb'|'co'|'cs'|'cy'|'da'|'de'|'doi'|'dv'|'ee'|'el'|'en'|'eo'|'es'|'et'|'eu'|'fa'|'fi'|'fr'|'fy'|'ga'|'gd'|'gl'|'gn'|'gom'|'gu'|'ha'|'haw'|'hi'|'hmn'|'hr'|'ht'|'hu'|'hy'|'id'|'ig'|'ilo'|'is'|'it'|'iw'|'ja'|'jw'|'ka'|'kk'|'km'|'kn'|'ko'|'kri'|'ku'|'ky'|'la'|'lb'|'lg'|'ln'|'lo'|'lt'|'lus'|'lv'|'mai'|'mg'|'mi'|'mk'|'ml'|'mn'|'mni-mtei'|'mr'|'ms'|'mt'|'my'|'ne'|'nl'|'no'|'nso'|'ny'|'om'|'or'|'pa'|'pl'|'ps'|'pt'|'qu'|'ro'|'ru'|'rw'|'sa'|'sd'|'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' export const GOOGLE_LANGUAGE: TargetFilter['google'][] = ['af','ak','am','ar','as','ay','az','be','bg','bho','bm','bn','bs','ca','ceb','ckb','co','cs','cy','da','de','doi','dv','ee','el','en','eo','es','et','eu','fa','fi','fr','fy','ga','gd','gl','gn','gom','gu','ha','haw','hi','hmn','hr','ht','hu','hy','id','ig','ilo','is','it','iw','ja','jw','ka','kk','km','kn','ko','kri','ku','ky','la','lb','lg','ln','lo','lt','lus','lv','mai','mg','mi','mk','ml','mn','mni-mtei','mr','ms','mt','my','ne','nl','no','nso','ny','om','or','pa','pl','ps','pt','qu','ro','ru','rw','sa','sd','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'] - +export const GOOGLE_LANGUAGE_OBJECT: { [p in GOOGLE_LIST]: string } = {"af":"Afrikaans","ak":"Twi","am":"Amharic","ar":"Arabic","as":"Assamese","ay":"Aymara","az":"Azerbaijani","be":"Belarusian","bg":"Bulgarian","bho":"Bhojpuri","bm":"Bambara","bn":"Bengali","bs":"Bosnian","ca":"Catalan","ceb":"Cebuano","ckb":"Kurdish (Sorani)","co":"Corsican","cs":"Czech","cy":"Welsh","da":"Danish","de":"German","doi":"Dogri","dv":"Dhivehi","ee":"Ewe","el":"Greek","en":"English","eo":"Esperanto","es":"Spanish","et":"Estonian","eu":"Basque","fa":"Persian","fi":"Finnish","fr":"French","fy":"Frisian","ga":"Irish","gd":"Scots Gaelic","gl":"Galician","gn":"Guarani","gom":"Konkani","gu":"Gujarati","ha":"Hausa","haw":"Hawaiian","hi":"Hindi","hmn":"Hmong","hr":"Croatian","ht":"Haitian Creole","hu":"Hungarian","hy":"Armenian","id":"Indonesian","ig":"Igbo","ilo":"Ilocano","is":"Icelandic","it":"Italian","iw":"Hebrew","ja":"Japanese","jw":"Javanese","ka":"Georgian","kk":"Kazakh","km":"Khmer","kn":"Kannada","ko":"Korean","kri":"Krio","ku":"Kurdish (Kurmanji)","ky":"Kyrgyz","la":"Latin","lb":"Luxembourgish","lg":"Luganda","ln":"Lingala","lo":"Lao","lt":"Lithuanian","lus":"Mizo","lv":"Latvian","mai":"Maithili","mg":"Malagasy","mi":"Maori","mk":"Macedonian","ml":"Malayalam","mn":"Mongolian","mni-mtei":"Meiteilon (Manipuri)","mr":"Marathi","ms":"Malay","mt":"Maltese","my":"Myanmar (Burmese)","ne":"Nepali","nl":"Dutch","no":"Norwegian","nso":"Sepedi","ny":"Chichewa","om":"Oromo","or":"Odia (Oriya)","pa":"Punjabi","pl":"Polish","ps":"Pashto","pt":"Portuguese","qu":"Quechua","ro":"Romanian","ru":"Russian","rw":"Kinyarwanda","sa":"Sanskrit","sd":"Sindhi","si":"Sinhala","sk":"Slovak","sl":"Slovenian","sm":"Samoan","sn":"Shona","so":"Somali","sq":"Albanian","sr":"Serbian","st":"Sesotho","su":"Sundanese","sv":"Swedish","sw":"Swahili","ta":"Tamil","te":"Telugu","tg":"Tajik","th":"Thai","ti":"Tigrinya","tk":"Turkmen","tl":"Filipino","tr":"Turkish","ts":"Tsonga","tt":"Tatar","ug":"Uyghur","uk":"Ukrainian","ur":"Urdu","uz":"Uzbek","vi":"Vietnamese","xh":"Xhosa","yi":"Yiddish","yo":"Yoruba","zh-cn":"Chinese (Simplified)","zh-tw":"Chinese (Traditional)","zu":"Zulu"} export type BING_LIST = 'af'|'am'|'ar'|'as'|'az'|'ba'|'bg'|'bho'|'bn'|'bo'|'brx'|'bs'|'ca'|'cs'|'cy'|'da'|'de'|'doi'|'dsb'|'dv'|'el'|'en'|'es'|'et'|'eu'|'fa'|'fi'|'fil'|'fj'|'fo'|'fr'|'fr-ca'|'ga'|'gl'|'gom'|'gu'|'ha'|'he'|'hi'|'hr'|'hsb'|'ht'|'hu'|'hy'|'id'|'ig'|'ikt'|'is'|'it'|'iu'|'iu-latn'|'ja'|'ka'|'kk'|'km'|'kmr'|'kn'|'ko'|'ks'|'ku'|'ky'|'ln'|'lo'|'lt'|'lug'|'lv'|'lzh'|'mai'|'mg'|'mi'|'mk'|'ml'|'mn-cyrl'|'mn-mong'|'mr'|'ms'|'mt'|'mww'|'my'|'nb'|'ne'|'nl'|'nso'|'nya'|'or'|'otq'|'pa'|'pl'|'prs'|'ps'|'pt'|'pt-pt'|'ro'|'ru'|'run'|'rw'|'sd'|'si'|'sk'|'sl'|'sm'|'sn'|'so'|'sq'|'sr-cyrl'|'sr-latn'|'st'|'sv'|'sw'|'ta'|'te'|'th'|'ti'|'tk'|'tlh-latn'|'tn'|'to'|'tr'|'tt'|'ty'|'ug'|'uk'|'ur'|'uz'|'vi'|'xh'|'yo'|'yua'|'yue'|'zh-hans'|'zh-hant'|'zu' export const BING_LANGUAGE: TargetFilter['microsoft'][] = ['af','am','ar','as','az','ba','bg','bho','bn','bo','brx','bs','ca','cs','cy','da','de','doi','dsb','dv','el','en','es','et','eu','fa','fi','fil','fj','fo','fr','fr-ca','ga','gl','gom','gu','ha','he','hi','hr','hsb','ht','hu','hy','id','ig','ikt','is','it','iu','iu-latn','ja','ka','kk','km','kmr','kn','ko','ks','ku','ky','ln','lo','lt','lug','lv','lzh','mai','mg','mi','mk','ml','mn-cyrl','mn-mong','mr','ms','mt','mww','my','nb','ne','nl','nso','nya','or','otq','pa','pl','prs','ps','pt','pt-pt','ro','ru','run','rw','sd','si','sk','sl','sm','sn','so','sq','sr-cyrl','sr-latn','st','sv','sw','ta','te','th','ti','tk','tlh-latn','tn','to','tr','tt','ty','ug','uk','ur','uz','vi','xh','yo','yua','yue','zh-hans','zh-hant','zu'] +export const BING_LANGUAGE_OBJECT: { [p in BING_LIST]: string } = {"af":"Afrikaans","am":"Amharic","ar":"Arabic","as":"Assamese","az":"Azerbaijani","ba":"Bashkir","bg":"Bulgarian","bho":"Bhojpuri","bn":"Bangla","bo":"Tibetan","brx":"Bodo","bs":"Bosnian","ca":"Catalan","cs":"Czech","cy":"Welsh","da":"Danish","de":"German","doi":"Dogri","dsb":"Lower Sorbian","dv":"Divehi","el":"Greek","en":"English","es":"Spanish","et":"Estonian","eu":"Basque","fa":"Persian","fi":"Finnish","fil":"Filipino","fj":"Fijian","fo":"Faroese","fr":"French","fr-ca":"French (Canada)","ga":"Irish","gl":"Galician","gom":"Konkani","gu":"Gujarati","ha":"Hausa","he":"Hebrew","hi":"Hindi","hr":"Croatian","hsb":"Upper Sorbian","ht":"Haitian Creole","hu":"Hungarian","hy":"Armenian","id":"Indonesian","ig":"Igbo","ikt":"Inuinnaqtun","is":"Icelandic","it":"Italian","iu":"Inuktitut","iu-latn":"Inuktitut (Latin)","ja":"Japanese","ka":"Georgian","kk":"Kazakh","km":"Khmer","kmr":"Kurdish (Northern)","kn":"Kannada","ko":"Korean","ks":"Kashmiri","ku":"Kurdish (Central)","ky":"Kyrgyz","ln":"Lingala","lo":"Lao","lt":"Lithuanian","lug":"Ganda","lv":"Latvian","lzh":"Chinese (Literary)","mai":"Maithili","mg":"Malagasy","mi":"Māori","mk":"Macedonian","ml":"Malayalam","mn-cyrl":"Mongolian (Cyrillic)","mn-mong":"Mongolian (Traditional)","mr":"Marathi","ms":"Malay","mt":"Maltese","mww":"Hmong Daw","my":"Myanmar (Burmese)","nb":"Norwegian","ne":"Nepali","nl":"Dutch","nso":"Sesotho sa Leboa","nya":"Nyanja","or":"Odia","otq":"Querétaro Otomi","pa":"Punjabi","pl":"Polish","prs":"Dari","ps":"Pashto","pt":"Portuguese (Brazil)","pt-pt":"Portuguese (Portugal)","ro":"Romanian","ru":"Russian","run":"Rundi","rw":"Kinyarwanda","sd":"Sindhi","si":"Sinhala","sk":"Slovak","sl":"Slovenian","sm":"Samoan","sn":"Shona","so":"Somali","sq":"Albanian","sr-cyrl":"Serbian (Cyrillic)","sr-latn":"Serbian (Latin)","st":"Sesotho","sv":"Swedish","sw":"Swahili","ta":"Tamil","te":"Telugu","th":"Thai","ti":"Tigrinya","tk":"Turkmen","tlh-latn":"Klingon (Latin)","tn":"Setswana","to":"Tongan","tr":"Turkish","tt":"Tatar","ty":"Tahitian","ug":"Uyghur","uk":"Ukrainian","ur":"Urdu","uz":"Uzbek (Latin)","vi":"Vietnamese","xh":"Xhosa","yo":"Yoruba","yua":"Yucatec Maya","yue":"Cantonese (Traditional)","zh-hans":"Chinese Simplified","zh-hant":"Chinese Traditional","zu":"Zulu"} export type BING_TTS_LIST = 'af'|'am'|'ar'|'bn'|'bg'|'ca'|'cs'|'cy'|'da'|'de'|'el'|'en'|'es'|'et'|'fa'|'fi'|'fr'|'fr-ca'|'ga'|'gu'|'he'|'hi'|'hr'|'hu'|'id'|'is'|'it'|'ja'|'kk'|'km'|'kn'|'ko'|'lo'|'lv'|'lt'|'mk'|'ml'|'mr'|'ms'|'mt'|'my'|'nl'|'nb'|'pl'|'ps'|'pt'|'pt-pt'|'ro'|'ru'|'sk'|'sl'|'sr-cyrl'|'sv'|'ta'|'te'|'th'|'tr'|'uk'|'ur'|'uz'|'vi'|'zh-hans'|'zh-hant'|'yue' export const MICROSOFT_TTS_LIST: { code: BING_TTS_LIST; language: string; gender: 'Male' | 'Female'; model: string }[] = [{"code":"af","language":"af-ZA","gender":"Female","model":"af-ZA-AdriNeural"},{"code":"am","language":"am-ET","gender":"Female","model":"am-ET-MekdesNeural"},{"code":"ar","language":"ar-SA","gender":"Male","model":"ar-SA-HamedNeural"},{"code":"bn","language":"bn-IN","gender":"Female","model":"bn-IN-TanishaaNeural"},{"code":"bg","language":"bg-BG","gender":"Male","model":"bg-BG-BorislavNeural"},{"code":"ca","language":"ca-ES","gender":"Female","model":"ca-ES-JoanaNeural"},{"code":"cs","language":"cs-CZ","gender":"Male","model":"cs-CZ-AntoninNeural"},{"code":"cy","language":"cy-GB","gender":"Female","model":"cy-GB-NiaNeural"},{"code":"da","language":"da-DK","gender":"Female","model":"da-DK-ChristelNeural"},{"code":"de","language":"de-DE","gender":"Female","model":"de-DE-KatjaNeural"},{"code":"el","language":"el-GR","gender":"Male","model":"el-GR-NestorasNeural"},{"code":"en","language":"en-US","gender":"Female","model":"en-US-AriaNeural"},{"code":"es","language":"es-ES","gender":"Female","model":"es-ES-ElviraNeural"},{"code":"et","language":"et-EE","gender":"Female","model":"et-EE-AnuNeural"},{"code":"fa","language":"fa-IR","gender":"Female","model":"fa-IR-DilaraNeural"},{"code":"fi","language":"fi-FI","gender":"Female","model":"fi-FI-NooraNeural"},{"code":"fr","language":"fr-FR","gender":"Female","model":"fr-FR-DeniseNeural"},{"code":"fr-ca","language":"fr-CA","gender":"Female","model":"fr-CA-SylvieNeural"},{"code":"ga","language":"ga-IE","gender":"Female","model":"ga-IE-OrlaNeural"},{"code":"gu","language":"gu-IN","gender":"Female","model":"gu-IN-DhwaniNeural"},{"code":"he","language":"he-IL","gender":"Male","model":"he-IL-AvriNeural"},{"code":"hi","language":"hi-IN","gender":"Female","model":"hi-IN-SwaraNeural"},{"code":"hr","language":"hr-HR","gender":"Male","model":"hr-HR-SreckoNeural"},{"code":"hu","language":"hu-HU","gender":"Male","model":"hu-HU-TamasNeural"},{"code":"id","language":"id-ID","gender":"Male","model":"id-ID-ArdiNeural"},{"code":"is","language":"is-IS","gender":"Female","model":"is-IS-GudrunNeural"},{"code":"it","language":"it-IT","gender":"Male","model":"it-IT-DiegoNeural"},{"code":"ja","language":"ja-JP","gender":"Female","model":"ja-JP-NanamiNeural"},{"code":"kk","language":"kk-KZ","gender":"Female","model":"kk-KZ-AigulNeural"},{"code":"km","language":"km-KH","gender":"Female","model":"km-KH-SreymomNeural"},{"code":"kn","language":"kn-IN","gender":"Female","model":"kn-IN-SapnaNeural"},{"code":"ko","language":"ko-KR","gender":"Female","model":"ko-KR-SunHiNeural"},{"code":"lo","language":"lo-LA","gender":"Female","model":"lo-LA-KeomanyNeural"},{"code":"lv","language":"lv-LV","gender":"Female","model":"lv-LV-EveritaNeural"},{"code":"lt","language":"lt-LT","gender":"Female","model":"lt-LT-OnaNeural"},{"code":"mk","language":"mk-MK","gender":"Female","model":"mk-MK-MarijaNeural"},{"code":"ml","language":"ml-IN","gender":"Female","model":"ml-IN-SobhanaNeural"},{"code":"mr","language":"mr-IN","gender":"Female","model":"mr-IN-AarohiNeural"},{"code":"ms","language":"ms-MY","gender":"Male","model":"ms-MY-OsmanNeural"},{"code":"mt","language":"mt-MT","gender":"Female","model":"mt-MT-GraceNeural"},{"code":"my","language":"my-MM","gender":"Female","model":"my-MM-NilarNeural"},{"code":"nl","language":"nl-NL","gender":"Female","model":"nl-NL-ColetteNeural"},{"code":"nb","language":"nb-NO","gender":"Female","model":"nb-NO-PernilleNeural"},{"code":"pl","language":"pl-PL","gender":"Female","model":"pl-PL-ZofiaNeural"},{"code":"ps","language":"ps-AF","gender":"Female","model":"ps-AF-LatifaNeural"},{"code":"pt","language":"pt-BR","gender":"Female","model":"pt-BR-FranciscaNeural"},{"code":"pt-pt","language":"pt-PT","gender":"Female","model":"pt-PT-FernandaNeural"},{"code":"ro","language":"ro-RO","gender":"Male","model":"ro-RO-EmilNeural"},{"code":"ru","language":"ru-RU","gender":"Female","model":"ru-RU-DariyaNeural"},{"code":"sk","language":"sk-SK","gender":"Male","model":"sk-SK-LukasNeural"},{"code":"sl","language":"sl-SI","gender":"Male","model":"sl-SI-RokNeural"},{"code":"sr-cyrl","language":"sr-RS","gender":"Female","model":"sr-RS-SophieNeural"},{"code":"sv","language":"sv-SE","gender":"Female","model":"sv-SE-SofieNeural"},{"code":"ta","language":"ta-IN","gender":"Female","model":"ta-IN-PallaviNeural"},{"code":"te","language":"te-IN","gender":"Male","model":"te-IN-ShrutiNeural"},{"code":"th","language":"th-TH","gender":"Male","model":"th-TH-NiwatNeural"},{"code":"tr","language":"tr-TR","gender":"Female","model":"tr-TR-EmelNeural"},{"code":"uk","language":"uk-UA","gender":"Female","model":"uk-UA-PolinaNeural"},{"code":"ur","language":"ur-IN","gender":"Female","model":"ur-IN-GulNeural"},{"code":"uz","language":"uz-UZ","gender":"Female","model":"uz-UZ-MadinaNeural"},{"code":"vi","language":"vi-VN","gender":"Male","model":"vi-VN-NamMinhNeural"},{"code":"zh-hans","language":"zh-CN","gender":"Female","model":"zh-CN-XiaoxiaoNeural"},{"code":"zh-hant","language":"zh-CN","gender":"Female","model":"zh-CN-XiaoxiaoNeural"},{"code":"yue","language":"zh-HK","gender":"Female","model":"zh-HK-HiuGaaiNeural"}] - export type YANDEX_LIST = 'af'|'am'|'ar'|'az'|'ba'|'be'|'bg'|'bn'|'bs'|'ca'|'ceb'|'cs'|'cv'|'cy'|'da'|'de'|'el'|'emj'|'en'|'eo'|'es'|'et'|'eu'|'fa'|'fi'|'fr'|'ga'|'gd'|'gl'|'gu'|'he'|'hi'|'hr'|'ht'|'hu'|'hy'|'id'|'is'|'it'|'ja'|'jv'|'ka'|'kazlat'|'kk'|'km'|'kn'|'ko'|'ky'|'la'|'lb'|'lo'|'lt'|'lv'|'mg'|'mhr'|'mi'|'mk'|'ml'|'mn'|'mr'|'mrj'|'ms'|'mt'|'my'|'ne'|'nl'|'no'|'pa'|'pap'|'pl'|'pt'|'ro'|'ru'|'sah'|'si'|'sjn'|'sk'|'sl'|'sq'|'sr'|'su'|'sv'|'sw'|'ta'|'te'|'tg'|'th'|'tl'|'tr'|'tt'|'udm'|'uk'|'ur'|'uz'|'uzbcyr'|'vi'|'xh'|'yi'|'zh'|'zu' export const YANDEX_LANGUAGE: TargetFilter['yandex'][] = ['af','am','ar','az','ba','be','bg','bn','bs','ca','ceb','cs','cv','cy','da','de','el','emj','en','eo','es','et','eu','fa','fi','fr','ga','gd','gl','gu','he','hi','hr','ht','hu','hy','id','is','it','ja','jv','ka','kazlat','kk','km','kn','ko','ky','la','lb','lo','lt','lv','mg','mhr','mi','mk','ml','mn','mr','mrj','ms','mt','my','ne','nl','no','pa','pap','pl','pt','ro','ru','sah','si','sjn','sk','sl','sq','sr','su','sv','sw','ta','te','tg','th','tl','tr','tt','udm','uk','ur','uz','uzbcyr','vi','xh','yi','zh','zu'] - +export const YANDEX_LANGUAGE_OBJECT: { [p in YANDEX_LIST]: string } = {"af":"Afrikaans","am":"Amharic","ar":"Arabic","az":"Azerbaijani","ba":"Bashkir","be":"Belarusian","bg":"Bulgarian","bn":"Bengali","bs":"Bosnian","ca":"Catalan","ceb":"Cebuano","cs":"Czech","cv":"Chuvash","cy":"Welsh","da":"Danish","de":"German","el":"Greek","emj":"Emoji","en":"English","eo":"Esperanto","es":"Spanish","et":"Estonian","eu":"Basque","fa":"Persian","fi":"Finnish","fr":"French","ga":"Irish","gd":"Scottish Gaelic","gl":"Galician","gu":"Gujarati","he":"Hebrew","hi":"Hindi","hr":"Croatian","ht":"Haitian","hu":"Hungarian","hy":"Armenian","id":"Indonesian","is":"Icelandic","it":"Italian","ja":"Japanese","jv":"Javanese","ka":"Georgian","kazlat":"Kazakh (Latin)","kk":"Kazakh","km":"Khmer","kn":"Kannada","ko":"Korean","ky":"Kyrgyz","la":"Latin","lb":"Luxembourgish","lo":"Lao","lt":"Lithuanian","lv":"Latvian","mg":"Malagasy","mhr":"Mari","mi":"Maori","mk":"Macedonian","ml":"Malayalam","mn":"Mongolian","mr":"Marathi","mrj":"Hill Mari","ms":"Malay","mt":"Maltese","my":"Burmese","ne":"Nepali","nl":"Dutch","no":"Norwegian","pa":"Punjabi","pap":"Papiamento","pl":"Polish","pt":"Portuguese","ro":"Romanian","ru":"Russian","sah":"Yakut","si":"Sinhalese","sjn":"Elvish (Sindarin)","sk":"Slovak","sl":"Slovenian","sq":"Albanian","sr":"Serbian","su":"Sundanese","sv":"Swedish","sw":"Swahili","ta":"Tamil","te":"Telugu","tg":"Tajik","th":"Thai","tl":"Tagalog","tr":"Turkish","tt":"Tatar","udm":"Udmurt","uk":"Ukrainian","ur":"Urdu","uz":"Uzbek","uzbcyr":"Uzbek (Cyrillic)","vi":"Vietnamese","xh":"Xhosa","yi":"Yiddish","zh":"Chinese","zu":"Zulu"} export type DEEPL_LIST = 'ar'|'bg'|'cs'|'da'|'de'|'el'|'en'|'en-gb'|'en-us'|'es'|'et'|'fi'|'fr'|'ga'|'hr'|'hu'|'id'|'is'|'it'|'ja'|'ko'|'lt'|'lv'|'mt'|'nb'|'nl'|'no'|'pl'|'pt'|'pt-br'|'pt-pt'|'ro'|'ru'|'sk'|'sl'|'sv'|'tr'|'uk'|'zh' export const DEEPL_LANGUAGE: TargetFilter['deepl'][] = ['ar','bg','cs','da','de','el','en','en-gb','en-us','es','et','fi','fr','ga','hr','hu','id','is','it','ja','ko','lt','lv','mt','nb','nl','no','pl','pt','pt-br','pt-pt','ro','ru','sk','sl','sv','tr','uk','zh'] - +export const DEEPL_LANGUAGE_OBJECT: { [p in DEEPL_LIST]: string } = {"ar":"Arabic","bg":"Bulgarian","cs":"Czech","da":"Danish","de":"German","el":"Greek","en":"English","en-gb":"English (British)","en-us":"English (American)","es":"Spanish","et":"Estonian","fi":"Finnish","fr":"French","ga":"Irish","hr":"Croatian","hu":"Hungarian","id":"Indonesian","is":"Icelandic","it":"Italian","ja":"Japanese","ko":"Korean","lt":"Lithuanian","lv":"Latvian","mt":"Maltese","nb":"Norwegian (bokmål)","nl":"Dutch","no":"Norwegian","pl":"Polish","pt":"Portuguese","pt-br":"Portuguese (Brazilian)","pt-pt":"Portuguese","ro":"Romanian","ru":"Russian","sk":"Slovak","sl":"Slovenian","sv":"Swedish","tr":"Turkish","uk":"Ukrainian","zh":"Chinese (simplified)"} export type BAIDU_LIST = 'ach'|'afr'|'aka'|'alb'|'amh'|'ara'|'arg'|'arm'|'arq'|'asm'|'ast'|'aym'|'aze'|'bak'|'bal'|'baq'|'bel'|'bem'|'ben'|'ber'|'bho'|'bis'|'bli'|'bos'|'bre'|'bul'|'bur'|'cat'|'ceb'|'chr'|'cht'|'chv'|'cor'|'cos'|'cre'|'cri'|'cs'|'dan'|'de'|'div'|'el'|'en'|'eno'|'epo'|'est'|'fao'|'fil'|'fin'|'fra'|'fri'|'frm'|'frn'|'fry'|'ful'|'geo'|'gla'|'gle'|'glg'|'glv'|'gra'|'grn'|'guj'|'hak'|'hau'|'haw'|'heb'|'hi'|'hil'|'hkm'|'hmn'|'hrv'|'ht'|'hu'|'hup'|'ibo'|'ice'|'id'|'ido'|'iku'|'ina'|'ing'|'it'|'jav'|'jp'|'kab'|'kah'|'kal'|'kan'|'kas'|'kau'|'kin'|'kir'|'kli'|'kok'|'kon'|'kor'|'kur'|'lag'|'lao'|'lat'|'lav'|'lim'|'lin'|'lit'|'log'|'loj'|'los'|'ltz'|'lug'|'mac'|'mah'|'mai'|'mal'|'mao'|'mar'|'mau'|'may'|'mg'|'mlt'|'mot'|'nbl'|'nea'|'nep'|'nl'|'nno'|'nob'|'nor'|'nqo'|'nya'|'oci'|'oji'|'ori'|'orm'|'oss'|'pam'|'pan'|'pap'|'ped'|'per'|'pl'|'pot'|'pt'|'pus'|'que'|'ro'|'roh'|'rom'|'ru'|'ruy'|'san'|'sco'|'sec'|'sha'|'sil'|'sin'|'sk'|'slo'|'sm'|'sme'|'sna'|'snd'|'sol'|'som'|'sot'|'spa'|'src'|'srd'|'srp'|'sun'|'swa'|'swe'|'syr'|'tam'|'tat'|'tel'|'tet'|'tgk'|'tgl'|'th'|'tir'|'tr'|'tso'|'tua'|'tuk'|'twi'|'ukr'|'ups'|'urd'|'ven'|'vie'|'wel'|'wln'|'wol'|'wyw'|'xho'|'yid'|'yor'|'yue'|'zaz'|'zh'|'zul' export const BAIDU_LANGUAGE: TargetFilter['baidu'][] = ['ach','afr','aka','alb','amh','ara','arg','arm','arq','asm','ast','aym','aze','bak','bal','baq','bel','bem','ben','ber','bho','bis','bli','bos','bre','bul','bur','cat','ceb','chr','cht','chv','cor','cos','cre','cri','cs','dan','de','div','el','en','eno','epo','est','fao','fil','fin','fra','fri','frm','frn','fry','ful','geo','gla','gle','glg','glv','gra','grn','guj','hak','hau','haw','heb','hi','hil','hkm','hmn','hrv','ht','hu','hup','ibo','ice','id','ido','iku','ina','ing','it','jav','jp','kab','kah','kal','kan','kas','kau','kin','kir','kli','kok','kon','kor','kur','lag','lao','lat','lav','lim','lin','lit','log','loj','los','ltz','lug','mac','mah','mai','mal','mao','mar','mau','may','mg','mlt','mot','nbl','nea','nep','nl','nno','nob','nor','nqo','nya','oci','oji','ori','orm','oss','pam','pan','pap','ped','per','pl','pot','pt','pus','que','ro','roh','rom','ru','ruy','san','sco','sec','sha','sil','sin','sk','slo','sm','sme','sna','snd','sol','som','sot','spa','src','srd','srp','sun','swa','swe','syr','tam','tat','tel','tet','tgk','tgl','th','tir','tr','tso','tua','tuk','twi','ukr','ups','urd','ven','vie','wel','wln','wol','wyw','xho','yid','yor','yue','zaz','zh','zul'] +export const BAIDU_LANGUAGE_OBJECT: { [p in BAIDU_LIST]: string } = {"ach":"亚齐语","afr":"南非荷兰语","aka":"阿肯语","alb":"阿尔巴尼亚语","amh":"阿姆哈拉语","ara":"阿拉伯语","arg":"阿拉贡语","arm":"亚美尼亚语","arq":"阿尔及利亚阿拉伯语","asm":"阿萨姆语","ast":"阿斯图里亚斯语","aym":"艾马拉语","aze":"阿塞拜疆语","bak":"巴什基尔语","bal":"俾路支语","baq":"巴斯克语","bel":"白俄罗斯语","bem":"本巴语","ben":"孟加拉语","ber":"柏柏尔语","bho":"博杰普尔语","bis":"比斯拉马语","bli":"比林语","bos":"波斯尼亚语","bre":"布列塔尼语","bul":"保加利亚语","bur":"缅甸语","cat":"加泰罗尼亚语","ceb":"宿务语","chr":"切罗基语","cht":"中文(繁体)","chv":"楚瓦什语","cor":"康瓦尔语","cos":"科西嘉语","cre":"克里克语","cri":"克里米亚鞑靼语","cs":"捷克语","dan":"丹麦语","de":"德语","div":"迪维希语","el":"希腊语","en":"英语","eno":"古英语","epo":"世界语","est":"爱沙尼亚语","fao":"法罗语","fil":"菲律宾语","fin":"芬兰语","fra":"法语","fri":"弗留利语","frm":"中古法语","frn":"加拿大法语","fry":"西弗里斯语","ful":"富拉尼语","geo":"格鲁吉亚语","gla":"盖尔语","gle":"爱尔兰语","glg":"加利西亚语","glv":"曼克斯语","gra":"古希腊语","grn":"瓜拉尼语","guj":"古吉拉特语","hak":"哈卡钦语","hau":"豪萨语","haw":"夏威夷语","heb":"希伯来语","hi":"印地语","hil":"希利盖农语","hkm":"高棉语","hmn":"苗语","hrv":"克罗地亚语","ht":"海地语","hu":"匈牙利语","hup":"胡帕语","ibo":"伊博语","ice":"冰岛语","id":"印尼语","ido":"伊多语","iku":"伊努克提图特语","ina":"因特语","ing":"印古什语","it":"意大利语","jav":"爪哇语","jp":"日语","kab":"卡拜尔语","kah":"卡舒比语","kal":"格陵兰语","kan":"卡纳达语","kas":"克什米尔语","kau":"卡努里语","kin":"卢旺达语","kir":"吉尔吉斯语","kli":"克林贡语","kok":"孔卡尼语","kon":"刚果语","kor":"韩语","kur":"库尔德语","lag":"拉特加莱语","lao":"老挝语","lat":"拉丁语","lav":"拉脱维亚语","lim":"林堡语","lin":"林加拉语","lit":"立陶宛语","log":"低地德语","loj":"逻辑语","los":"下索布语","ltz":"卢森堡语","lug":"卢干达语","mac":"马其顿语","mah":"马绍尔语","mai":"迈蒂利语","mal":"马拉雅拉姆语","mao":"毛利语","mar":"马拉地语","mau":"毛里求斯克里奥尔语","may":"马来语","mg":"马拉加斯语","mlt":"马耳他语","mot":"黑山语","nbl":"南恩德贝莱语","nea":"那不勒斯语","nep":"尼泊尔语","nl":"荷兰语","nno":"新挪威语","nob":"书面挪威语","nor":"挪威语","nqo":"西非书面语","nya":"齐切瓦语","oci":"奥克语","oji":"奥杰布瓦语","ori":"奥里亚语","orm":"奥罗莫语","oss":"奥塞梯语","pam":"邦板牙语","pan":"旁遮普语","pap":"帕皮阿门托语","ped":"北索托语","per":"波斯语","pl":"波兰语","pot":"巴西葡萄牙语","pt":"葡萄牙语","pus":"普什图语","que":"克丘亚语","ro":"罗姆语","roh":"罗曼什语","rom":"罗马尼亚语","ru":"俄语","ruy":"卢森尼亚语","san":"梵语","sco":"苏格兰语","sec":"塞尔维亚-克罗地亚语","sha":"掸语","sil":"西里西亚语","sin":"僧伽罗语 ","sk":"斯洛伐克语","slo":"斯洛文尼亚语","sm":"萨摩亚语","sme":"北方萨米语","sna":"修纳语","snd":"信德语","sol":"桑海语","som":"索马里语","sot":"南索托语","spa":"西班牙语","src":"塞尔维亚语(西里尔文)","srd":"萨丁尼亚语","srp":"塞尔维亚语(拉丁文)","sun":"巽他语","swa":"斯瓦希里语","swe":"瑞典语","syr":"叙利亚语","tam":"泰米尔语","tat":"鞑靼语","tel":"泰卢固语","tet":"德顿语","tgk":"塔吉克语","tgl":"他加禄语","th":"泰语","tir":"提格利尼亚语","tr":"土耳其语","tso":"聪加语","tua":"突尼斯阿拉伯语","tuk":"土库曼语","twi":"契维语","ukr":"乌克兰语","ups":"高地索布语","urd":"乌尔都语","ven":"文达语","vie":"越南语","wel":"威尔士语","wln":"瓦隆语","wol":"沃洛夫语","wyw":"中文(文言文)","xho":"科萨语","yid":"意第绪语","yor":"约鲁巴语","yue":"中文(粤语)","zaz":"扎扎其语","zh":"中文(简体)","zul":"祖鲁语"} export type BAIDU_TTS_LIST = 'en'|'zh'|'yue'|'ara'|'kor'|'jp'|'th'|'pt'|'spa'|'fra'|'ru'|'de'|'uk' - export type SOGOU_LIST = 'ar'|'pl'|'da'|'de'|'ru'|'fr'|'fi'|'ko'|'nl'|'cs'|'pt'|'ja'|'sv'|'th'|'tr'|'es'|'hu'|'en'|'it'|'vi'|'zh-CHS' export const SOGOU_LANGUAGE: TargetFilter['sogou'][] = ['ar','pl','da','de','ru','fr','fi','ko','nl','cs','pt','ja','sv','th','tr','es','hu','en','it','vi','zh-CHS'] +export const SOGOU_LANGUAGE_OBJECT: { [p in SOGOU_LIST]: string } = {"ar":"阿拉伯语","pl":"波兰语","da":"丹麦语","de":"德语","ru":"俄语","fr":"法语","fi":"芬兰语","ko":"韩语","nl":"荷兰语","cs":"捷克语","pt":"葡萄牙语","ja":"日语","sv":"瑞典语","th":"泰语","tr":"土耳其语","es":"西班牙语","hu":"匈牙利语","en":"英语","it":"意大利语","vi":"越南语","zh-CHS":"中文"} export type SOGOU_TTS_LIST = Exclude diff --git a/tests/baidu.test.ts b/tests/baidu.test.ts index cad4da6..b96a579 100644 --- a/tests/baidu.test.ts +++ b/tests/baidu.test.ts @@ -1,6 +1,6 @@ import { describe, expect, test } from 'vitest' -import { BaiduLanguagePredict, BaiduTranslator, GetBaiduTranslatorToken, BaiduTTS } from '../lib/index.js' -import { GetBaiduTranslatorTokenResult } from '../lib/source/baidu.js' +import { BaiduLanguagePredict, BaiduTranslator, GetBaiduTranslatorToken, BaiduTTS } from '../dist/esm/index.js' +import type { GetBaiduTranslatorTokenResult } from '../lib/source/baidu.js' let globalPage: GetBaiduTranslatorTokenResult = { message: null, diff --git a/tests/deepl.test.ts b/tests/deepl.test.ts index eaed3f0..174f36f 100644 --- a/tests/deepl.test.ts +++ b/tests/deepl.test.ts @@ -1,5 +1,5 @@ import { describe, test } from 'vitest' -import { DeepL } from '../lib/index.js' +import { DeepL } from '../dist/esm/index.js' describe('DeepL translator(web)', () => { test.concurrent('English', async ({ expect }) => { diff --git a/tests/google.test.ts b/tests/google.test.ts index ef174db..a47e806 100644 --- a/tests/google.test.ts +++ b/tests/google.test.ts @@ -1,6 +1,5 @@ import { expect, test, describe } from 'vitest' -import { GoogleBrowserTranslate, GoogleTranslate, GoogleTTS } from '../lib/index.js' -import { GoogleTranslateTk } from '../lib/source/google.js' +import { GoogleBrowserTranslate, GoogleTranslate, GoogleTTS, GoogleTranslateTk } from '../dist/esm/index.js' test('Google TK', async () => { expect(GoogleTranslateTk('test content', [464385, 3806605782])).toEqual('531820.985965') diff --git a/tests/microsoft.test.ts b/tests/microsoft.test.ts index 3f10f36..ea88b18 100644 --- a/tests/microsoft.test.ts +++ b/tests/microsoft.test.ts @@ -1,5 +1,5 @@ import { describe, expect, test } from 'vitest' -import { GetMicrosoftBrowserTranslatorAuth, GetMicrosoftTranslatorToken, MicrosoftBrowserPredict, MicrosoftBrowserTranslator, MicrosoftTranslator, MicrosoftTTS } from '../lib/index.js' +import { GetMicrosoftBrowserTranslatorAuth, GetMicrosoftTranslatorToken, MicrosoftBrowserPredict, MicrosoftBrowserTranslator, MicrosoftTranslator, MicrosoftTTS } from '../dist/esm/index.js' let jwt = '' test('Microsoft edge jwt', async () => { diff --git a/tests/sogou.test.ts b/tests/sogou.test.ts index 16203bb..2206f29 100644 --- a/tests/sogou.test.ts +++ b/tests/sogou.test.ts @@ -1,5 +1,5 @@ import { describe, expect, test } from 'vitest' -import { SogouBrowserTranslator, SogouTTS } from '../lib/index.js' +import { SogouBrowserTranslator, SogouTTS } from '../dist/esm/index.js' describe('Sogou translator(browser)', () => { test.concurrent('English', async ({ expect }) => { diff --git a/tests/yandex.test.ts b/tests/yandex.test.ts index 29e74de..5280a95 100644 --- a/tests/yandex.test.ts +++ b/tests/yandex.test.ts @@ -1,5 +1,5 @@ import { describe, test } from 'vitest' -import { YandexDetect, YandexBrowserTranslator, YandexTranslator } from '../lib/index.js' +import { YandexDetect, YandexBrowserTranslator, YandexTranslator } from '../dist/esm/index.js' describe('Yandex predict', () => { test.concurrent('English', async ({ expect }) => {