added the language toggle functionality in the drawer section
Fixes #
Describe the changes you have made in this PR -
This PR improves the language switcher in the app drawer by turning it into a custom-designed toggle-like segmented control. Instead of a standard switch, it uses two stylized buttons ("English" and "हिंदी") to clearly represent the current language. The switcher is placed on the left side with an accompanying translate icon for better visual context.
- Replaced the basic language toggle with a visually appealing segmented control.
- Positioned the toggle on the left with an icon to enhance alignment and clarity.
- Added smooth animation to transitions between English and Hindi for better feedback.
- Ensured visual balance between both language options with consistent padding and minimum width.
- Improved accessibility and visual appeal by making the text size adaptive while keeping design consistency.
Screenshots of the changes (If any) -
Note: Please check Allow edits from maintainers. if you would like us to assist in the PR.
Summary by CodeRabbit
-
New Features
- Introduced an in-app language toggle enabling users to switch seamlessly between English and Hindi.
- Enhanced overall localization so the app dynamically updates content based on the selected language.
- Updated the user interface to remove development banners, ensuring a cleaner and more polished experience.
- Added a language selection feature within the drawer for improved accessibility.
-
Localization Updates
- Expanded localization files to include new entries for the term "Language" in both English and Hindi.
Walkthrough
This update introduces a dedicated LanguageController to manage the application's locale. A new LanguageController class is added to handle locale settings and toggling between English and Hindi. The application startup in main.dart is updated to initialize this controller and configure the localization settings, including a fallback locale and title generation. Additionally, the UI in the drawer is enhanced with a language selection feature using reactive widgets, allowing users to switch languages directly from the drawer.
Changes
| Files | Change Summary |
|---|---|
lib/controllers/language_controller.dart |
Added a new LanguageController class that extends GetxController. It manages an observable locale and provides methods to change and toggle the language selection state. |
lib/main.dart |
Integrated the LanguageController by adding an import statement, initializing it with Get.put(), and updating GetMaterialApp with locale settings and a fallback locale. The onGenerateTitle method's syntax was simplified. |
lib/ui/components/cv_drawer.dart |
Added a language selection feature in the CVDrawer class, including an Obx widget to react to language changes and an ExpansionTile for language options, allowing users to select between English and Hindi. |
lib/l10n/app_en.arb |
Added a new key-value pair "language": "Language" to the English localization file to expand localization capabilities. |
lib/l10n/app_hi.arb |
Added a new key-value pair "language": "भाषा" to the Hindi localization file and reformatted an existing string for consistent spacing. |
📜 Recent review details
Configuration used: CodeRabbit UI Review profile: CHILL Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between fc0ce7429f3c37cd9d864746c8a1b363e821ba0d and 963157164480989ff3c80a778487dff05b558be8.
📒 Files selected for processing (4)
-
lib/controllers/language_controller.dart(1 hunks) -
lib/l10n/app_en.arb(1 hunks) -
lib/l10n/app_hi.arb(1 hunks) -
lib/ui/components/cv_drawer.dart(5 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: build (windows-latest)
- GitHub Check: build (ubuntu-latest)
- GitHub Check: build (macos-latest)
🔇 Additional comments (5)
lib/l10n/app_hi.arb (1)
118-119: LGTM! Added Hindi translation for the language label.The translation for "language" has been properly added as "भाषा" in the Hindi localization file, which will be displayed in the new language toggle component in the drawer.
lib/l10n/app_en.arb (1)
118-119: LGTM! Added English translation for the language label.The localization string for "language" has been properly added to the English localization file, supporting the new language toggle feature in the drawer.
lib/controllers/language_controller.dart (1)
1-17: Well-structured controller for language management.The LanguageController follows good practices with GetX by:
- Using observable variables for reactive state management
- Implementing clear methods for changing language and toggling expansion
- Properly updating the app locale with Get.updateLocale()
The controller fulfills its responsibility of managing the application's language state.
lib/ui/components/cv_drawer.dart (2)
6-6: LGTM! Added import for the LanguageController.Properly imports the new controller for language management functionality.
46-100: Well-implemented language selection component in the drawer.The language toggle implementation:
- Uses reactive state management with Obx for automatic UI updates
- Provides clear visual feedback with radio buttons for selected language
- Follows existing drawer UI patterns for consistency
- Properly handles language changing and expansion state
This implementation nicely fulfills the PR objective of adding language toggle functionality to the drawer section.
🪧 Tips
Chat
There are 3 ways to chat with CodeRabbit:
- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
-
I pushed a fix in commit <commit_id>, please review it. -
Generate unit testing code for this file. -
Open a follow-up GitHub issue for this discussion.
-
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. Examples:-
@coderabbitai generate unit testing code for this file. -
@coderabbitai modularize this function.
-
- PR comments: Tag
@coderabbitaiin a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:-
@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase. -
@coderabbitai read src/utils.ts and generate unit testing code. -
@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format. -
@coderabbitai help me debug CodeRabbit configuration file.
-
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)
-
@coderabbitai pauseto pause the reviews on a PR. -
@coderabbitai resumeto resume the paused reviews. -
@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository. -
@coderabbitai full reviewto do a full review from scratch and review all the files again. -
@coderabbitai summaryto regenerate the summary of the PR. -
@coderabbitai generate docstringsto generate docstrings for this PR. -
@coderabbitai resolveresolve all the CodeRabbit review comments. -
@coderabbitai planto trigger planning for file edits and PR creation. -
@coderabbitai configurationto show the current CodeRabbit configuration for the repository. -
@coderabbitai helpto get help.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere in the PR title to generate the title automatically.
CodeRabbit Configuration File (.coderabbit.yaml)
- You can programmatically configure CodeRabbit by adding a
.coderabbit.yamlfile to the root of your repository. - Please see the configuration documentation for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation:
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
Documentation and Community
- Visit our Documentation for detailed information on how to use CodeRabbit.
- Join our Discord Community to get help, request features, and share feedback.
- Follow us on X/Twitter for updates and announcements.