-
Notifications
You must be signed in to change notification settings - Fork 1
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
Translate Experiment using a related "TranslatedContent" model #1204
Comments
Thank you for adding this! Perhaps we can also leave the language parameter to another issue. It might actually be less frustrating that way, since we don't want users to just go ahead and change the parameter, right? Right now, if a user sees What I haven't really thought through yet are scenarios as follows:
Do we then (as was now the case) give them a mixture of English and Spanish? Do we "force" the language cookie to one of the translations available for the experiment? I guess the latter. We would then probably select the language cookie as follows:
There should be a mechanism to check, when entering a new If we do implement the |
Yes, good idea. I'll add it as a future task.
Yes, I was also thinking about this and I agree with your approach. I'll make this approach explicit in the requirements. |
…iew as this has been replaced at the experiment level per #1204
* feat: Add translated_content model with FK to experiment and add migrations * fix: Fix reverse migration * feat: Remove experiment fields and migrations The commit removes the `name`, `description`, `consent`, and `about_content` fields from the `Experiment` model and updates the admin forms accordingly. * refactor: Only show an empty form for a newly to be created experiment * feat: Add fallback option to get_translated_content method This commit adds a `fallback` parameter to the `get_translated_content` method in the `Experiment` model. When set to `True`, if no content is found for the specified language, it will return the primary content instead. If `fallback` is set to `False` and no content is found, a `ValueError` will be raised. Refactor the `get_content` method to `get_translated_content` to better reflect its purpose. * refactor: Rename primary_content to fallback_content * fix(test): Fix & update tests after adding experiment translated content * chore: Rename primary content to fallback content * refactor: Use `get_language` instead of checking `request.LANGUAGE_CODE` * refactor: Remove unnecessary code for setting language in get_block view as this has been replaced at the experiment level per #1204 * refactor: Moving setting the language cookie from `get_block` to `get_experiment` * test: Add tests for getting the right language content based on the `Accept-Language` header's value * refactor: Delete all experiment translated content This commit modifies the migration file `0050_migrate_experiment_content_to_translatedmakemigrations.py` to delete all experiment translated content using the `ExperimentTranslatedContent.objects.all().delete()` method. This change is necessary to clean up the database and ensure that no translated content exists anymore after running the reverse migration. * fix: Fix ci by changing `docker-compose` command to `docker compose`
I don't think
|
ThemeConfig itself doesn't contain text, but As for |
Now that #1270 is closed, we can consider this done. |
Is your feature request related to a problem? Please describe.
Right now, we don't have a clear way to provide translated / localised / internationalised experiments to users. The only option we currently have is to create a "new Experiment" for a new language and write the title, description, etc. in that language. However, the app's non-experiment-related or non-configurable content (button's, links, translation keys in the experiment blocks) might still show up in a different language.
Describe the solution you'd like
A better way, as discussed on Tuesday July 23, might be to create a new model (named
ExperimentTranslatedContent
or something) which contains all the textual content of an experiment for a given language. In pseudocode, that model would look something like this:Which content should then be shown to the user?
Based on the preference from the client, in the form of a URL parameter (?lang=jp), we can serialise the experiment with the right language content and get a fallback in case the chosen language's content is not available.
Which fallback should then be chosen?
We could use the index to arrange the fallback priority order. In other words, if an ETC (Exp. Translated Content) for Dutch (nl) is listed on top (index = 0), it can be the fallback for an English ETC with index = 1.
Alternatively, we could think about a more elaborate system of fallbacks in the future if needed. An option could be a fallback_for property with an array of languages (en, nl) for an ETC and make Django check that list if it cannot find the content for a preferred language. E.g. the user prefers Catalan, but the Spanish ETC has
fallback_for=[ca,pt]
and therefore falls back to the Spanish ETC.Requirements
ExperimentTranslatedContent
(see pseudocode above)django-nested-admin
to create a nested inline form.ExperimentTranslatedContent
mandatory in order to create/save an experiment. (An Experiment without content should not be possible).get_experiment
's content according to the preferred language and make sure the json structure stays the same (so the frontend needs no revising)Accept-Language
header supplied by the browser.Accept-Language
header, fallback to the highest available experiment language content bases on the index (index=0 would be first fallback).Good to know / Future tasks
We will most likely have to do this for
ThemeConfig
andBlock
as well. I'll list these as a "todo" list below, which allows us to create issues from them easily whenever we want to:Block
using a related "TranslatedContent" model #1215ExperimentTranslatedContent
#1270TranslateI don't thinkThemeConfig
using a related "TranslatedContent" modelThemeConfig
contains any textual content shown to the user right? We might want to skip this one.[ ] Allow the user to select the language they want to see the experiment in. Use the following URL parameter:?lang=nl
#1259The text was updated successfully, but these errors were encountered: