gen_lang
gen_lang copied to clipboard
Best way to get all strings and save it in array?
Hi.
-
What would be the best way to get all the strings and save them in array? So I could use it in ListView?
-
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"
}
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)