Add automatic browser language detection and remove Tempo script error #21
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds automatic browser language detection to provide a better user experience by loading the site in the user's preferred language, and removes the Tempo script that was causing
ERR_ADDRESS_INVALIDconsole errors.Changes
1. Browser Language Detection (
src/hooks/useLanguage.ts)Added intelligent language detection that prioritizes user preference while respecting browser settings:
localStorageThe implementation uses a
getBrowserLanguage()helper that checks ifnavigator.languagestarts with "en" to detect English speakers, defaulting to French otherwise.2. Removed Tempo Script (
index.html)Removed the problematic Tempo error-handling script that was causing
ERR_ADDRESS_INVALIDerrors in the browser console:- <script src="https://api.tempolabs.ai/proxy-asset?url=https://storage.googleapis.com/tempo-public-assets/error-handling.js"></script>Testing
✅ Browser language detection: Verified site loads in English for English browsers
✅ User preference persistence: Language toggle choice persists across sessions
✅ Fallback behavior: Clearing localStorage correctly falls back to browser detection
✅ Console errors: No more ERR_ADDRESS_INVALID errors
✅ Build & lint: All checks pass successfully
✅ Security: No vulnerabilities detected by CodeQL
Screenshots
English (automatically detected from browser):

French (after manual toggle):

Impact
This provides a significantly improved user experience:
Original prompt
Add Automatic Browser Language Detection + Fix Tempo Script
Objectives
Changes Needed
1. Update useLanguage.ts - Add Browser Language Detection
File:
src/hooks/useLanguage.tsReplace entire file with:
2. Remove Tempo Script from index.html
File:
index.html(line 17)Current code:
Remove line 17 entirely:
How Language Detection Works
First Visit:
User Toggles Language:
localStorageNext Visit:
Expected Results
✅ Automatic language detection based on browser settings
✅ No Tempo errors in console (ERR_ADDRESS_INVALID fixed)
✅ User preference saved when manually toggling
✅ Smooth language transitions maintained
✅ English speakers see English automatically
✅ French speakers see French automatically
Testing
After deployment:
preferredLanguagekey after toggleFiles Changed (2 total)
src/hooks/useLanguage.ts- Add browser language detectionindex.html- Remove Tempo script causing errorThis pull request was created as a result of the following prompt from Copilot chat.
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.