gen_lang icon indicating copy to clipboard operation
gen_lang copied to clipboard

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

Open frojnd opened this issue 6 years ago • 1 comments

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"
}

frojnd avatar Jan 23 '20 12:01 frojnd

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)

AkoWu101 avatar Feb 06 '20 06:02 AkoWu101