From fb0cc81d1db0d88c90bb112a0caec66095fcc0f0 Mon Sep 17 00:00:00 2001 From: André Oliveira <37463445+SpecialAro@users.noreply.github.com> Date: Wed, 17 Aug 2022 22:54:41 +0100 Subject: Feature: Add Ferdium Translator (#548) Add feature to translate text natively using https://github.com/shikar/NODE_GOOGLE_TRANSLATE package and a LibreTranslate self-hosted option (already running on our server on https://translator.ferdium.org). --- src/config.ts | 139 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 139 insertions(+) (limited to 'src/config.ts') diff --git a/src/config.ts b/src/config.ts index 150b7101d..c8cb09d84 100644 --- a/src/config.ts +++ b/src/config.ts @@ -24,6 +24,8 @@ export const LIVE_WS_API = 'wss://api.franzinfra.com'; export const LOCAL_API_WEBSITE = 'http://localhost:3333'; export const DEV_API_FRANZ_WEBSITE = 'https://meetfranz.com'; export const LIVE_API_FERDIUM_WEBSITE = 'https://ferdium.org'; +export const LIVE_API_FERDIUM_LIBRETRANSLATE = + 'https://translator.ferdium.org/translate'; export const STATS_API = 'https://stats.franzinfra.com'; @@ -84,6 +86,140 @@ export const SEARCH_ENGINE_NAMES = { [SEARCH_ENGINE_DDG]: 'DuckDuckGo', }; +export const TRANSLATOR_ENGINE_GOOGLE = 'Google'; +export const TRANSLATOR_ENGINE_LIBRETRANSLATE = 'LibreTranslate'; +export const TRANSLATOR_ENGINE_NAMES = { + [TRANSLATOR_ENGINE_LIBRETRANSLATE]: + 'Ferdium Translator (Powered by LibreTranslate)', + [TRANSLATOR_ENGINE_GOOGLE]: 'Google', +}; + +export const LIBRETRANSLATE_TRANSLATOR_LANGUAGES = { + ar: 'Arabic', + zh: 'Chinese', + en: 'English', + fr: 'French', + de: 'German', + hi: 'Hindi', + id: 'Indonesian', + ga: 'Irish', + it: 'Italian', + ja: 'Japanese', + ko: 'Korean', + pl: 'Polish', + pt: 'Portuguese', + ru: 'Russian', + es: 'Spanish', + tr: 'Turkish', + vi: 'Vietnamese', +}; + +export const GOOGLE_TRANSLATOR_LANGUAGES = { + af: 'Afrikaans', + sq: 'Albanian', + ar: 'Arabic', + hy: 'Armenian', + az: 'Azerbaijani', + eu: 'Basque', + be: 'Belarusian', + bn: 'Bengali', + bs: 'Bosnian', + bg: 'Bulgarian', + ca: 'Catalan', + ceb: 'Cebuano', + ny: 'Chichewa', + 'zh-cn': 'Chinese Simplified', + 'zh-tw': 'Chinese Traditional', + co: 'Corsican', + hr: 'Croatian', + cs: 'Czech', + da: 'Danish', + nl: 'Dutch', + en: 'English', + eo: 'Esperanto', + et: 'Estonian', + tl: 'Filipino', + fi: 'Finnish', + fr: 'French', + fy: 'Frisian', + gl: 'Galician', + ka: 'Georgian', + de: 'German', + el: 'Greek', + gu: 'Gujarati', + ht: 'Haitian Creole', + ha: 'Hausa', + haw: 'Hawaiian', + iw: 'Hebrew', + hi: 'Hindi', + hmn: 'Hmong', + hu: 'Hungarian', + is: 'Icelandic', + ig: 'Igbo', + id: 'Indonesian', + ga: 'Irish', + it: 'Italian', + ja: 'Japanese', + jw: 'Javanese', + kn: 'Kannada', + kk: 'Kazakh', + km: 'Khmer', + ko: 'Korean', + ku: 'Kurdish (Kurmanji)', + ky: 'Kyrgyz', + lo: 'Lao', + la: 'Latin', + lv: 'Latvian', + lt: 'Lithuanian', + lb: 'Luxembourgish', + mk: 'Macedonian', + mg: 'Malagasy', + ms: 'Malay', + ml: 'Malayalam', + mt: 'Maltese', + mi: 'Maori', + mr: 'Marathi', + mn: 'Mongolian', + my: 'Myanmar (Burmese)', + ne: 'Nepali', + no: 'Norwegian', + ps: 'Pashto', + fa: 'Persian', + pl: 'Polish', + pt: 'Portuguese', + ma: 'Punjabi', + ro: 'Romanian', + ru: 'Russian', + sm: 'Samoan', + gd: 'Scots Gaelic', + sr: 'Serbian', + st: 'Sesotho', + sn: 'Shona', + sd: 'Sindhi', + si: 'Sinhala', + sk: 'Slovak', + sl: 'Slovenian', + so: 'Somali', + es: 'Spanish', + su: 'Sudanese', + sw: 'Swahili', + sv: 'Swedish', + tg: 'Tajik', + ta: 'Tamil', + te: 'Telugu', + th: 'Thai', + tr: 'Turkish', + uk: 'Ukrainian', + ur: 'Urdu', + uz: 'Uzbek', + vi: 'Vietnamese', + cy: 'Welsh', + xh: 'Xhosa', + yi: 'Yiddish', + yo: 'Yoruba', + zu: 'Zulu', +}; + export const SEARCH_ENGINE_URLS = { [SEARCH_ENGINE_STARTPAGE]: ({ searchTerm }) => `https://www.startpage.com/sp/search?query=${searchTerm}`, @@ -222,6 +358,7 @@ export const DEFAULT_APP_SETTINGS = { showMessageBadgeWhenMuted: true, showDragArea: false, enableSpellchecking: true, + enableTranslator: false, spellcheckerLanguage: 'en-us', darkMode: false, navigationBarManualActive: false, @@ -261,6 +398,8 @@ export const DEFAULT_APP_SETTINGS = { iconSize: iconSizeBias, navigationBarBehaviour: 'custom', searchEngine: SEARCH_ENGINE_STARTPAGE, + translatorLanguage: 'en', + translatorEngine: TRANSLATOR_ENGINE_LIBRETRANSLATE, useHorizontalStyle: false, hideCollapseButton: false, isMenuCollapsed: false, -- cgit v1.2.3-70-g09d2