Open tahini opened 3 months ago
For solution 2, I did something similar in generate_conditionals.py for relativePath (for example, when you want to get the relativePath of the group.)
# Check if any conditional has a path that contains "${relativePath}"
conditionals_has_path = any(
"${relativePath}" in conditional["path"] for conditional in conditionals
)
declare_relative_path = f"{INDENT}const relativePath = path.substring(0, path.lastIndexOf('.'));"
So we could have an extra sheet name LabelVariables
, with 3 columns:
If a widget has entries in the LabelVariables sheet, we replace the (t) => t(blabla)
with
(t, interview) => t(blabla, {
variableName: getResponse(interview, path),
});
Yes, that could work!
En passant, avec i18next, tu peux mettre le count en option à la fonction t et si count === 1, ça cherche le label avec le suffixe _one (et il y a plein d'autres features reliés à ça, mais c,est celui qu'on utilise le plus).
Par exemple, ici, tu aurais pu juste mettre t('household:age', { count: helper.countPersons(interview) }) au lieu du if/else et les deux libellés seraient age et age_one dans houshold.yml
from @tahini
We should add count like this.
Currently, the generator only accepts simple labels. If we want to add variables to the labels, eg. "Here follow questions about your trip to {{destination}}", we need to use a custom widget.
2 possible solutions (not mutually exclusive):
{{path after last dot}}
and they can be added to thet
function call.Solution 1 is relatively straightforward given the other custom stuff we have. @samuel-duhaime any idea how we could implement solution 2 to support multiple variables from the excel file?