-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Detect browser language for better localization #69
base: main
Are you sure you want to change the base?
Conversation
Warning Rate limit exceeded@harperreed has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 24 minutes and 24 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (1)
WalkthroughThe update enhances language initialization in the chat app. A new function, Changes
Sequence Diagram(s)sequenceDiagram
participant App as Application
participant IL as getInitialLanguage
participant Browser as Browser
participant System as System Locale
participant i18next as i18next Instance
App->>IL: Call getInitialLanguage()
alt Running on Web
IL->>Browser: Get navigator.language
Browser-->>IL: Return language
alt Language Supported?
IL-->>App: Return browser language
else
IL->>System: Get Localization.locale
System-->>IL: Return system language
alt Language Supported?
IL-->>App: Return system language
else
IL-->>App: Return default ('en')
end
end
else Not on Web
IL->>System: Get Localization.locale
System-->>IL: Return system language
alt Language Supported?
IL-->>App: Return system language
else
IL-->>App: Return default ('en')
end
end
App->>i18next: Initialize with chosen language
sequenceDiagram
participant App as Application
participant Storage as Saved Preferences
participant i18next as i18next Instance
App->>Storage: Retrieve saved language
alt Saved language ≠ current language
App->>i18next: Change language to saved value
else
note right of App: No change needed
end
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
❌ Deploy Preview for orbit-ing failed. Why did it fail? →
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (1)
packages/chat/app/i18n/config.ts
(3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (4)
- GitHub Check: Redirect rules - orbit-ing
- GitHub Check: Header rules - orbit-ing
- GitHub Check: Pages changed - orbit-ing
- GitHub Check: Cloudflare Pages
🔇 Additional comments (3)
packages/chat/app/i18n/config.ts (3)
4-4
: LGTM!The Platform import is correctly added for OS detection.
47-55
: LGTM!The i18next initialization correctly uses the new language detection logic.
58-62
: LGTM!The optimization to prevent unnecessary language changes is well implemented.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Pull Request: Enhance Language Detection for Chat Application
Summary
This pull request improves the initial language detection mechanism in the chat application's internationalization (i18n) configuration. It allows the application to correctly identify the user's language preference in web environments, enhancing user experience and accessibility.
Why
Many users access applications through web browsers where the language settings may not match the system language. By incorporating browser language detection alongside the existing Expo Localization method, we ensure that the application respects user preferences more accurately, providing a seamless experience for all users.
Changes Made
packages/chat/app/i18n/config.ts
getInitialLanguage
to determine the initial language based on:navigator.language
Localization.locale
Changes Outline
import { Platform } from 'react-native';
getInitialLanguage
function:lng
property in i18next configuration to usegetInitialLanguage()
.Closed Issues
This update aims to improve the overall user experience by ensuring that the application defaults to the most suitable language for users regardless of the platform they are using.
Summary by CodeRabbit