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
Collect strings from BubbleChoice sub-levels for translation #38629
Conversation
@Hamms I'd appreciate it if you could take a quick look at this PR :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
if level.is_a? BubbleChoice | ||
i18n_strings["sublevels"] = {} | ||
level.sublevels.map do |sublevel| | ||
i18n_strings["sublevels"][sublevel.name] = get_i18n_strings sublevel |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@daynew This will address your concern that translations should not depend on order of the sublevels. I've updated the PR description with a new output.
Btw, Level.name
is unique because of this validation:
validates_uniqueness_of :name, case_sensitive: false, conditions: -> {where.not(user_id: nil)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good as long as name
isn't something which changes often.
We're totally safe to depend on level names to be unique and immutable; many more critical things than the i18n sync would break if that assumption were to be violated |
FND-1250
Collect strings from BubbleChoice sub-levels for translation. This is the first step in making BubbleChoice sub-levels translatable. (The next step is to display translations properly in the Code studio.)
Example
The last lesson of Course D - 2020 is a end-of-course project. It is a
BubbleChoice
level, which allow students to choose from 1 of 4 types of project. Each specific project is a sub-level, for example this basketball project. Currently, i18n strings from a sub-level project such as its display name and instructions are not collected by thesync-in
process.Testing story
Test the
get_i18n_strings
function from the Rails consoleTest the
sync-in
process:bin/i18n/sync-in.rb
i18n/locales/source/course_content/2020/coursed-2020.json
contains strings from all BubbleChoice levels and their sub-levels. The result looks like this