-
Notifications
You must be signed in to change notification settings - Fork 5
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
Add natural translation for DSL #574
base: master
Are you sure you want to change the base?
Conversation
Maybe we could support translations of a testplan (and rollout of templates?) as
with an extra option (or argument) to pass the natural language for the translation. |
This should work. |
@pdawyndt in #559 it also says that translations for files should be provided. In what sense? - files: !natural_language
en:
- name: "file.txt"
url: "media/workdir/file.txt"
nl:
- name: "fileNL.txt"
url: "media/workdir/fileNL.txt" This seems pointless since I could also just do: - files:
- name: "file.txt"
url: "media/workdir/file.txt"
- name: "fileNL.txt"
url: "media/workdir/fileNL.txt" |
Not really pointless as TESTed will show all "linked files" to the students. For each file, TESTed will try to find its name in the expression/statement and then turn that into a hyperlink. If it doesn't find the filename, it will add it to a list of files that is displayed for the testcase. |
@pdawyndt , I started looking for adding a translation table like translation:
animal:
en: "animal"
nl: "dier"
result:
en: "result"
nl: "resultaat" Is it even usefull to then also add support in a statement like the following: - statement: !natural_language
en: 'result = Trying(10, "{animal}")'
nl: 'resultaat = Proberen(10, "{animal}")' I would suggest not even searching lookingany deeper when a natural_language map is already found and only using translation map when the expected (like a string) is given. |
I definitely have many exercises where this (the combination of translation and template strings) is useful. So I would say yes. If we use Python format strings, then we could even write your example as - statement: !natural_language
en: 'result = Trying(10, {animal!r})'
nl: 'resultaat = Proberen(10, {animal!r})' And not even bother about using single or double quotes or escaping any quotes in the thing you put in the placeholders (which otherwise adds a lot of complication on the side of the DSL-author). If you have a variable statement = statement.format(**translation, **data) If we also allow data to be an YAML-array instead of a YAML map (positional instead of named placeholders), then formatting is done by statement = statement.format(*data, **translation) For example, if '{} + {} = {}' or with explicit positions (which would also allow reodering and reusing the array values) '{0} + {1} = {2}' |
Currently I've implemented support for The
|
You can run the pre-processor by using
python -m tested.nat_translation ./exercise/simple-example/program_language_map/suite.yaml en # English translation