Testing the Translation Feature¶
Issue Fixed¶
The translation feature was not showing as available, even in Chrome Beta with Experimental Web Features enabled. This was because the code was using the old Translation API specification (self.translation.createTranslator), but the current specification uses Translator.create().
Changes Made¶
- Updated TypeScript interfaces: Changed from
TranslationAPIinterface withself.translationtoTranslatorConstructorinterface withwindow.Translator - Updated browser support check: Changed from
self.translation.canTranslate()toTranslator.availability() - Updated translator creation: Changed from
self.translation.createTranslator()toTranslator.create() - Updated documentation: All documentation now reflects the new API specification
- Updated tests: All tests now check for
window.Translatorinstead ofself.translation
How to Test¶
Prerequisites¶
- Chrome Canary, Dev, or Beta (Version 128+)
-
Download from: https://www.google.com/chrome/canary/ or https://www.google.com/chrome/beta/
-
Enable Translation API Flags:
- Open Chrome and navigate to:
chrome://flags - Search for and enable these flags:
#translation-api- Enable Translation API#enable-experimental-web-platform-features- Enable experimental features
- Restart Chrome
Testing Steps¶
-
Build the application:
-
Start the dev server:
-
Open in Chrome Canary/Beta:
- Navigate to
http://localhost:5173 -
Open Developer Console (F12)
-
Check API availability:
- In the console, type:
-
Should return
trueif the API is available -
Then check availability for a language pair:
-
Should return one of:
'available','downloadable','downloading', or'unavailable' -
Verify UI:
- If the API is available (
!== 'unavailable'), you should see:- ✅ Translation dropdown in the navigation menu
- ✅ Language selector showing 12 languages
-
If the API is not available, you should see:
- ✅ "Translation not available" link in the header
- ✅ Tooltip explaining requirements when clicked
-
Test Translation:
- Select a language from the dropdown (e.g., "Español (Spanish)")
- The content should translate (may take a moment for first translation as model downloads)
- Warning banner should appear at the top
- Select "English (Original)" to restore original content
Expected Console Output¶
When the page loads, you should see console messages like:
orIf the API is not supported:
Troubleshooting¶
If translation dropdown doesn't appear:
1. Check console for errors
2. Verify flags are enabled and Chrome was restarted
3. Ensure you're using Chrome Canary/Dev/Beta version 128+
4. Try manually checking: window.Translator in console
If Translator is undefined:
- The Translation API may not be fully rolled out in your Chrome version yet
- Try Chrome Canary for the latest experimental features
- Verify both flags are enabled
If availability returns 'unavailable': - This is expected on some systems/configurations - The API is still in development and may not be available everywhere - Use browser's built-in translation (right-click → Translate) as fallback
API Specification Reference¶
The new Translation API specification can be found at: - https://github.com/WICG/translation-api - https://chromestatus.com/feature/5182950152642560
Key differences from old API:
- Old: self.translation.createTranslator()
- New: Translator.create()
- Old: self.translation.canTranslate()
- New: Translator.availability()
Next Steps¶
If translation still doesn't work after these changes: 1. Check Chrome release notes for Translation API status 2. Verify the API specification hasn't changed again 3. Test with a minimal example to isolate the issue 4. File a bug report with Chrome team if needed
Success Criteria¶
✅ Build completes without errors ✅ All 69 tests pass ✅ TypeScript compilation successful ✅ Console shows correct API detection ✅ UI shows translation controls when API is available ✅ UI shows fallback message when API is not available