diff --git a/src/app/features/settings/general/General.tsx b/src/app/features/settings/general/General.tsx index 6b2c54c6e..7f25ad901 100644 --- a/src/app/features/settings/general/General.tsx +++ b/src/app/features/settings/general/General.tsx @@ -108,6 +108,7 @@ import { TRANSLATE_TARGET_LANGUAGES, normalizeLang, isSupportedTargetLang, + translationUnavailableText, } from '../../../utils/translation/langUtils'; import { chromeTranslationEngine } from '../../../utils/translation/chromeEngine'; import { SequenceCardStyle } from '../styles.css'; @@ -2756,7 +2757,7 @@ function Messages() { description={ translationSupported ? 'Translate messages written in other languages into this one. Runs entirely on your device — message text never leaves your computer or touches a cloud service.' - : 'On-device translation isn’t available in this browser. Use a Chromium desktop browser (Chrome/Edge 138+) or the Lotus desktop app.' + : translationUnavailableText(isTauriEnv()) } after={ { assert.equal(new Set(codes).size, codes.length); assert.ok(codes.includes('en')); }); + +test('translationUnavailableText: no "use the desktop app" inside the desktop app (#349)', () => { + assert.doesNotMatch(translationUnavailableText(true), /desktop app\.$|Lotus desktop app/); + assert.match(translationUnavailableText(true), /this version of the desktop app/); + assert.match(translationUnavailableText(false), /this browser/); +}); diff --git a/src/app/utils/translation/langUtils.ts b/src/app/utils/translation/langUtils.ts index 9ae545f37..e260aff95 100644 --- a/src/app/utils/translation/langUtils.ts +++ b/src/app/utils/translation/langUtils.ts @@ -86,6 +86,16 @@ export function isSupportedTargetLang(code: string): boolean { return CURATED_NAME.has(normalizeLang(code)); } +/** + * [Gitea #349] Why translation is unavailable, by platform. The desktop app + * on Linux/macOS (WebKit) lacks the on-device APIs too, so it must not send + * people to "the Lotus desktop app" they're already using. + */ +export const translationUnavailableText = (desktopApp: boolean): string => + desktopApp + ? 'On-device translation isn’t available in this version of the desktop app. It works in Chrome or Edge 138+ on a computer.' + : 'On-device translation isn’t available in this browser. Use Chrome or Edge 138+ on a computer.'; + /** Pure: why a manual Translate did nothing (#287). */ export const translateSkipMessage = (from: string | undefined, targetLang: string): string => from