Skip to content

Refactor local settings to use localization strings#1045

Merged
hjiangsu merged 3 commits intodevelopfrom
refactor/settings-localization
Jan 15, 2024
Merged

Refactor local settings to use localization strings#1045
hjiangsu merged 3 commits intodevelopfrom
refactor/settings-localization

Conversation

@hjiangsu
Copy link
Copy Markdown
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
Copy Markdown
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
@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