Skip to content

Commit

Permalink
Localize long instructions for Lab2 levels (#57994)
Browse files Browse the repository at this point in the history
  • Loading branch information
sanchitmalhotra126 committed Apr 13, 2024
1 parent f0320b0 commit 87d7e89
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
12 changes: 0 additions & 12 deletions dashboard/app/models/levels/blockly.rb
Original file line number Diff line number Diff line change
Expand Up @@ -453,18 +453,6 @@ def blockly_level_options
options.freeze
end

# FND-985 Create shared API to get localized level properties.
def get_localized_property(property_name)
if should_localize? && try(property_name)
I18n.t(
name,
scope: [:data, property_name],
default: nil,
smart: true
)
end
end

def localized_failure_message_override
get_localized_property('failure_message_override')
end
Expand Down
13 changes: 13 additions & 0 deletions dashboard/app/models/levels/level.rb
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,18 @@ def localized_panels
end
end

# FND-985 Create shared API to get localized level properties.
def get_localized_property(property_name)
if should_localize? && try(property_name)
I18n.t(
name,
scope: [:data, property_name],
default: nil,
smart: true
)
end
end

# There's a bit of trickery here. We consider a level to be
# hint_prompt_enabled for the sake of the level editing experience if any of
# the scripts associated with the level are hint_prompt_enabled.
Expand Down Expand Up @@ -834,6 +846,7 @@ def summarize_for_lab2_properties(script)
# Localized properties
properties_camelized["validations"] = localized_validations if properties_camelized["validations"]
properties_camelized["panels"] = localized_panels if properties_camelized["panels"]
properties_camelized["longInstructions"] = (get_localized_property("long_instructions") || long_instructions) if properties_camelized["longInstructions"]
properties_camelized
end

Expand Down

0 comments on commit 87d7e89

Please sign in to comment.