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

Best way to get all strings and save it in array? #12

Open
frojnd opened this issue Jan 23, 2020 · 1 comment
Open

Best way to get all strings and save it in array? #12

frojnd opened this issue Jan 23, 2020 · 1 comment

Comments

@frojnd
Copy link

frojnd commented Jan 23, 2020

Hi.

  1. What would be the best way to get all the strings and save them in array? So I could use it in ListView?

  2. Is it possible to "categorize" strings inside string_en.json file? Or if not, what would be the best logic to save into array just strings that starts with card_category1_?

{
  "card_category1_test": "test",
  "card_category1_abc": "abc",
  "card_category2_test": "Another test",
  "card_category2_abc": "Another abc"
}
@KingWu
Copy link
Owner

KingWu commented Feb 6, 2020

For question 1, currently, need to write a helper function which contain many switch cases to map with a specific function

Maybe enhance for the future with following solutions.

S.of(context).localized(name, args)
eg.

S.of(context).localized('card_category1.test')

For question 2,
Thinking of using json structure

{
  "card_category1": {
	"test": "test"
	"abc": "abc"
  },
  "card_category2": {
	"test": "Another test"
	"abc": "Another abc"
  }
}

But, the generated function name will be tricky. Thats why we need a generalize function like S.of(context).localized(name, args)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants