Translations of app messages#138
Conversation
…m user input and choosen language if files changed; add translations to ui.R functions
|
Hi Stefan, how are translations of the actual question and response text handled? |
That's not what this PR is about. This is about being able to provide alternative labels for all the hard-coded messaging throughout the app, like the pop-up window that comes up if you have a required question that you didn't answer. Currently all of those messages are hard-coded in English and users have no way to modify it. This PR addresses that and lets the user specify alternative text to use. If you wanted to have a different language version of a survey question, that is something you can already define as a user by just using different labels in With this in mind, I don't think "translations" is the appropriate thing to call this whole idea, because (as @StefanMunnes mentioned) this could be used to change the messages / labels to anything, not just another language. It could remain in English, but you just may want to use different phrasing, etc. I think something like "system_text" or "app_text" to make it clear that this is not "labels", which is might be associated with "question labels". This is all the other text in the system / app. |
|
Hi and yes, @jhelvy is absolutely right in describing what I did. It's not about the labelling of the questions and answers, it's about the integrated system and the navigation messages. To also give the user the option to have them in the language of respondents from other countries, like Germany in my case. That's where the idea of "translations" comes from, but as I wrote, I now also think it makes more sense to formulate this whole process and the files rather as app_text, survey_text, system_text, or similar. And I also thought that was what I was asking for in the feature request ;) |
|
I need to find some time to look through this, but I think we're aligned on what the goal is here. I think |
|
I would not completely throw the concept of translation overboard in the proposed PR for two reasons:
The fact that there is a translations.yml file in the _survey folder also has two reasons:
This means that there can be two translations.yml (or app_text.yml) files. Always one in the _survey folder, which is a process and output file as written. As well as a user-created file in the root directory that provides parts or all of the changes/translations for the text elements. This file can also contain translations for multiple languages and only the selected language is then used. I think this approach is a good template for the questions.yml files. We have already implemented the files in the _survey folder with all the questions that are actually used. Now you could also have a questions.yml file provided by the user in the root directory, which contains a collection of questions that could be used via the IDs in survey.qmd. |
|
And besides the default English text elements, I provided four more translations users can use without manually providing a file: de, es, fr, and it. Of course, we can discuss which of them is necessary, but why not? I would assume the usage as following: 60% use the default setting "en" And the way I have implemented it, the list and the translations.yml files are defined via the language at the top level translations <- list(
'en' = list(
"cancel" = 'Cancel',
"confirm_exit" = 'Confirm Exit',
...
)
)To sum it up, I think the translation is the focal point in terms of logic and usage. What the files are called in the end is not important to me, but the documentation of the implementation should make that clear. |
|
Okay, I think I understand. I still haven't had a chance to look through the code (probably won't for a few more days), but I just wanted to make sure I'm understanding what you did. I thought (perhaps incorrectly) that you were proposing users put a So am I correct that users can set a We'll have to do a good job writing up the documentation on the main website. I think maybe just add a new |
|
Correct, this is exactly how it works with my implementation. I can try to prepare a page for the documentation, but you want to finally decide for a name of the two files? |
|
I don't disagree with translation probably being the primary use case for this, but I'm concerned people might think this is for translating the entire survey (e.g., see the above comment by @warnes). It could easily be mis-interpreted. A more precise description is it allows you to override the default text to all system messages in the survey. For that reason, I still lean towards calling the yml files something else, but we could still use a word related to "language". Maybe |
|
Okay I finally got a chance to go through this. I made some changes, hopefully you'll agree with them. The biggest change is I did not like that you have a global I then changed what you previously had as I also added the Also, in Finally, when I documented the package I got warning messages about the non-ASCII characters in the Can you take a look at these changes and see if everything still seems to be working? |
|
I like all the changes and agree with them. The Unicode encoding also works (tested for German). |
|
Awesome. I just fixed one more small bug I found. For matrix questions, the stored |
|
I'm going to run the documentation again on this then will merge this as v0.4.2. |
|
Okay a few more updates:
|
I have finally managed it and am very happy with the implementation!
4.1 in server.R are:
4.2 in ui.R these are:
I have decided to make the translations available in ui.R as well. On the one hand, there are settings that the user cannot access themselves (e.g. date input, redirect elements). On the other hand, it saves effort for the user and is in the same workflow now. I have written the labels for the Next and Exit buttons so that they are only overwritten if it is not in English and the default has not been changed. So if something is entered manually, this always applies.
There is also the option for users to provide a translations.yml file in the root folder and replace all or individual text elements for a specified language with it. This is then also imported and populated in the corresponding language. In the event of problems, it always falls back to English.
This approach allows users to systematically change individual text elements, which would otherwise not be possible or would require significantly more effort. Changing the accessible label in survey.qmd is still possible without any problems.
However, I was wondering whether it's really still about translations or whether we should call it text_elements, survey_labels, or something similar. After all, phrases can also be adapted in English in this way.
I think this approach is promising and now gives me a good feeling of how a questions.yml file provided by the user can be implemented.