-
Notifications
You must be signed in to change notification settings - Fork 599
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 feature to parse text in the lesson definition. #202
base: master
Are you sure you want to change the base?
Conversation
I suppose using markers such as
It could even be implemented with a named vector of replacements in the question's
Probably |
I like this idea however I think we should use whisker as a template engine. We could specify a localization file that would look something like this: - locale: en_US.UTF-8
hello: Good morning!
- locale: de_DE.UTF-8
hello: Guten morgen! And then the question in the
We would render the |
@odeleongt Thanks for the pull request! I think this is a really cool idea, but I agree with @seankross that it's worth using the whisker package if we're going to do it. |
Yeah, I thought about whisker but I have never used it, so just munched this code to record the idea. Whisker looks great to manage translations (i.e. seems easy enough to extract the language from the locale), but it looks like it would be difficult to design a lesson which needs to consider locales and take into account everything. I think it is really out of scope to try and provide a static and comprehensive localization info, for instance to work with dates/times, currency or numeric representations (i.e. many options related to If this is to be implemented, whisker seems like the correct choice for templating, but I do think it would be useful to include the option to parse code at startup in addition to defining locale/language specific values. |
I updated the pull request to use whisker to process the lesson definition file. It checks if a If the file exists, it loads the file, loads the lesson, replaces the text, saves the lesson as a temporary file and returns a new file path for the lesson (code in There is only a placeholder to process the localization file. ¿How would you go about it? Defining text replacements based on one of |
I suppose that the first element of the Given the variety of locale naming conventions, I think that most uses would come from evaluating R expressions instead of defining localization rules. I think it would be a nice feature (and would help solve the problem of localization by defining locale independent expressions which evaluate to the correct locale dependent representation), but I don't know if it is within the goals of swirl and worth the hassle. |
@odeleongt Thanks again for putting this together. I have a full plate at the moment and may not have a chance to fully review/test this for another week or two. Perhaps @seankross and @WilCrofter could give their blessing in the meantime. |
@ncarchedi Haven't been following but will do what I can as time permits. |
Where do we stand on this? I apologize for being so out of the loop. |
Thanks for the follow up. I've been thinking about this, and it seems that the work I proposed would be useful only for minor tweaking of a lesson as it is displayed to the user. What happens if someone needs to set up a ´swirl´ training environment in a non-English speaking location? For instance, my employer is requesting some very specific R/epi training modules, and I would like to use swirl to provide self-paced practice materials and also enable them to access the suggested courses; the problem is that the audience exclusively speaks Spanish. I'm planning to translate the suggested courses (no big deal) and would prepare the specific training modules in Spanish, but given that the intended audience is also new to R / scripting I think that even presenting the messages and menus in English could deter them from effectively following the course. To fix this, two things would be needed:
If you are interested, and we can work out an organized plan to do it, I could get my employer to allow me some time to work on it. |
Earlier in development, we considered internationalization of swirl menus etc. The prototype is in swirl's languages branch. The effort has not been a priority for a very long time, and I doubt the branch is current. I could try to update it if anyone is interested. Let me know. The general idea was that menu content be specified as key:value pairs in yaml files. Keys were beginnings of the en values, enough to identify the specific item. I used Google Translate to create a Spanish yaml file which, I'm sure, is inadequate but demonstrated the idea. |
Backward compatible changes which allow to process lesson definitions which request some marker (e.g.
-_-
) to be replaced with text generated with an R expression upon loading the lesson.Written to fix an issue due to locale-specific translation of character strings with
strptime
.Fixes #201.
Lesson specification should be used as in odeleongt/swirl_courses@53ff493.