Skip to content
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

Refactor local settings to use localization strings #1045

Merged
merged 3 commits into from
Jan 15, 2024

Conversation

hjiangsu
Copy link
Member

Pull Request Description

This PR adds a way to get a localized string based on a key/string. Flutter does not support mirrors, so this approach is more manual. It requires us to create a map between the key and the localization string. The following changes were made:

  • Renamed label to key in LocalSettings enum. This was done because it makes more semantic sense.
  • Created an extension on AppLocalizations with a new function getLocalSettingLocalization. This function takes in a key, and outputs the associated localization string.
  • Refactored the existing code to handle the new changes

Note: for each new setting we add, we also need to add in the corresponding entry into the map so that it can be associates with the proper localization string.

Reference: https://stackoverflow.com/questions/55445624/how-to-get-a-property-by-this-name-in-string

Issue Being Fixed

This relates to #1036 and hopefully provides a way to allow for localized strings for the search functionality.

Issue Number: N/A

Screenshots / Recordings

Checklist

  • Did you update CHANGELOG.md?
  • Did you use localized strings where applicable?
  • Did you add semanticLabels where applicable for accessibility?

@hjiangsu hjiangsu mentioned this pull request Jan 12, 2024
3 tasks
Copy link
Member

@micahmo micahmo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@hjiangsu hjiangsu merged commit 0a18529 into develop Jan 15, 2024
1 check passed
@hjiangsu hjiangsu deleted the refactor/settings-localization branch January 15, 2024 17:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants