-
Notifications
You must be signed in to change notification settings - Fork 209
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
feat: Multiple Language support added #1071
base: flutter_app
Are you sure you want to change the base?
Conversation
Reviewer's Guide by SourceryThe pull request implements multi-language support by adding a localization system that currently supports English and Chinese languages. The implementation uses Flutter's localization framework with JSON-based translation files and includes a locale provider to manage language switching. Class diagram for localization implementationclassDiagram
class AppLocalizations {
+Locale? locale
+Map<String, String> _localizedStrings
+Future loadJsonLanguage()
+String translate(String key)
+String translateWithArgs(String key, Map<String, dynamic> args)
}
class _AppLocalizationsDelegate {
+bool isSupported(Locale locale)
+Future<AppLocalizations> load(Locale locale)
+bool shouldReload(LocalizationsDelegate old)
}
class LocaleProvider {
+Locale _locale
+Locale get locale()
+void changeLocale(Locale newLocale)
}
AppLocalizations --> _AppLocalizationsDelegate : delegate
AppLocalizations --> Locale : locale
LocaleProvider --> Locale : manages
AppLocalizations --> "1" Map : _localizedStrings
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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.
Hey @Dhruv80576 - I've reviewed your changes - here's some feedback:
Overall Comments:
- Consider creating a constants file for translation keys (e.g.,
translation_keys.dart
) to avoid string literals and make maintenance easier. This would help prevent typos and make refactoring simpler.
Here's what I looked at during the review
- 🟡 General issues: 1 issue found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
} | ||
|
||
// Method to translate a key into a localized string | ||
String translate(String key) => _localizedStrings[key] ?? ""; |
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.
suggestion: Consider adding debug logging for missing translation keys
In debug mode, log a warning when a translation key is missing to help catch issues during development.
String translate(String key) => _localizedStrings[key] ?? ""; | |
String translate(String key) { | |
final value = _localizedStrings[key]; | |
if (value == null) { | |
assert(() { | |
print('Missing translation key: $key'); | |
return true; | |
}()); | |
} | |
return value ?? ''; | |
} |
I think we can hop onto a different and scalable solution. More info: #927 |
Fix #1067
Setting now updated, added language switch option. Now this application supports chinese language also.
Please find the video attached.
Screen_recording_20241103_180601.mp4
Summary by Sourcery
Add multiple language support to the application, including a language switch option and support for Chinese. Implement a localization system to manage translations using JSON files.
New Features:
Enhancements: