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

Sync named function parameters to Crowdin #34973

Merged
merged 2 commits into from
May 27, 2020
Merged

Conversation

bethanyaconnor
Copy link
Contributor

This PR adds the named parameters to the function_definitions object for each level. I'll create a separate PR to actually use the translations.

Example:

  "https://studio.code.org/p/artist": {
   ...
    "function_definitions": {
      "draw a star": {
        "name": "draw a star",
        "description": "draw a star with given points and sides of given length",
        "parameters": {
          "points": "points",
          "length": "length"
        }
      },
      "draw a circle": {
        "name": "draw a circle",
        "description": "draw a circle of given radius",
        "parameters": {
          "radius": "radius"
        }
      }
      ...
  }
}

Links

Testing story

Reviewer Checklist:

  • Tests provide adequate coverage
  • 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

@bethanyaconnor bethanyaconnor requested a review from a team as a code owner May 26, 2020 22:27
Copy link
Contributor

@Hamms Hamms left a comment

Choose a reason for hiding this comment

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

I'd love to see this get DRYed out a bit. Something like

      functions.each do |function|
        name = function.at_xpath('./title[@name="NAME"]')
        description = function.at_xpath('./mutation/description')
        parameters = function.xpath('./mutation/arg').map do |parameter|
          [parameter["name"], parameter["name"]]
        end.to_h

        definition = Hash.new
        definition["name"] = name.content if name
        definition["description"] = description.content if description
        definition["parameters"] = parameters unless parameters.empty?

        i18n_strings['function_definitions'][name.content] = definition
      end

@bethanyaconnor
Copy link
Contributor Author

Good call. I'll update it.

@bethanyaconnor bethanyaconnor requested a review from Hamms May 27, 2020 20:03
@bethanyaconnor bethanyaconnor merged commit f6df8d3 into staging May 27, 2020
@bethanyaconnor bethanyaconnor deleted the sync-named-parameters branch May 27, 2020 20:06
@bethanyaconnor bethanyaconnor mentioned this pull request May 29, 2020
7 tasks
@bethanyaconnor bethanyaconnor mentioned this pull request Jun 26, 2020
7 tasks
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

2 participants