Skip to content
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 display names and descriptions for lesson extras #39969

Merged
merged 2 commits into from
Apr 9, 2021

Conversation

hacodeorg
Copy link
Contributor

@hacodeorg hacodeorg commented Apr 8, 2021

FND-1467
This change does 2 things

  1. Adds level's description to the i18n pipeline
  2. Renders translated level's display names and descriptions correctly in the lesson extras view (or stage_extras view).

Before (https://studio.code.org/s/coursef-2020/stage/3/extras/lang/es-mx)
Screen Shot 2021-04-07 at 6 40 57 PM

After (on localhost)
Screen Shot 2021-04-07 at 6 40 19 PM

Testing story

  • Ran sync-in.rb to produce i18n/locales/source/course_content/2020/coursef-2020.json below. Verified it could extract the level's display_name and bubble_choice_description.

    {
      "https://studio.code.org/s/coursef-2020/stage/3/extras?level_name=spritelab_extras_repeat": {
        "display_name": "Lots of sprites!",
        "bubble_choice_description": "Create many matching sprites quickly using loops!",
      }
    }
  • Created a fake sync-down result at i18n/locales/es-MX/course_content/2020/coursef-2020.json with translations

    {
      "https://studio.code.org/s/coursef-2020/stage/3/extras?level_name=spritelab_extras_repeat": {
        "display_name": "es-MX translated display name",
        "bubble_choice_description": "es-MX translated bubble choice description",
      }
    }
  • Ran sync-out.rb and verified that the display name and description are distributed correctly to dashboard/config/locales/display_name.es-MX.json

    {
      "es-MX": {
        "data": {
          "display_name": {
            "spritelab_extras_repeat": "es-MX translated display name"
          }
        }
      }
    }

    and dashboard/config/locales/bubble_choice_description.es-MX.json.

    {
      "es-MX": {
        "data": {
          "bubble_choice_description": {
            "spritelab_extras_repeat": "es-MX translated bubble choice description"
          }
        }
      }
    }
  • Verified that lesson extra were displayed correctly in different languages

  • Verified that the rendering code is safe against user-generated content.
    Rendering display_name:

    <a
    href={this.getSublevelUrl()}
    style={styles.title}
    className="sublevel-card-title-uitest"
    >
    {sublevel.display_name}
    </a>

    Rendering description:
    <div
    style={styles.description}
    className="sublevel-card-description-uitest"
    >
    {sublevel.description}
    </div>

    Both are safe because we just treat them as plain strings.

PR Checklist:

  • Tests provide adequate coverage
  • Privacy and Security impacts have been assessed
  • Code is well-commented
  • New features are translatable or updates will not break translations
  • Relevant documentation has been added or updated
  • User impact is well-understood and desirable
  • Pull Request is labeled appropriately
  • Follow-up work items (including potential tech debt) are tracked and linked

@hacodeorg hacodeorg marked this pull request as ready for review April 8, 2021 02:02
@hacodeorg hacodeorg requested a review from a team as a code owner April 8, 2021 02:02
@hacodeorg hacodeorg requested a review from dmcavoy April 8, 2021 17:27
Copy link
Member

@daynew daynew left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow thank you for the thorough PR explanation!!!!

@hacodeorg hacodeorg merged commit f4887ed into staging Apr 9, 2021
@hacodeorg hacodeorg deleted the ha/translate-extra-lessons branch April 9, 2021 03:29
Copy link
Contributor

@dmcavoy dmcavoy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this Ha!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants