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

Resolve #414 Add Language Support #474

Merged
merged 13 commits into from
Oct 18, 2023
Merged

Resolve #414 Add Language Support #474

merged 13 commits into from
Oct 18, 2023

Conversation

mzagaja
Copy link
Member

@mzagaja mzagaja commented Sep 27, 2023

  • Return question text and response text in English by default, but use the headers provided by ACCEPT_LANGUAGE to pick the available language.
  • Update how we import sample data.

Current sample output hitting /surveys/1.json

{
  "id": 1,
  "title": "Draft Survey",
  "updated_at": "2023-09-26T23:42:54.764Z",
  "survey_questions": [
    {
      "id": 1,
      "display_order": 1,
      "text": "Have you heard of heat pumps?",
      "response_type": "radio",
      "response_options": [
        "Yes",
        "No"
      ]
    },
    {
      "id": 2,
      "display_order": 2,
      "text": "If yes, have you considered them for home heating/cooling?",
      "response_type": "radio",
      "response_options": [
        "Yes",
        "No"
      ]
    },
    {
      "id": 3,
      "display_order": 3,
      "text": "If yes, how far have you taken your interest in heat pumps?",
      "response_type": "text",
      "response_options": []
    },
    {
      "id": 4,
      "display_order": 4,
      "text": "Have you heard of Mass Save… the energy efficieny program?",
      "response_type": "radio",
      "response_options": [
        "Yes",
        "No"
      ]
    },
    {
      "id": 5,
      "display_order": 5,
      "text": "If yes, have you had contact with them?",
      "response_type": "radio",
      "response_options": [
        "Yes",
        "No"
      ]
    },
    {
      "id": 6,
      "display_order": 6,
      "text": "If you could save money on your utility bills with a state-discounted or free heating/cooling system upgrade, would you like to learn more?",
      "response_type": "radio",
      "response_options": [
        "Yes",
        "No"
      ]
    },
    {
      "id": 7,
      "display_order": 7,
      "text": "If yes, please confirm your name",
      "response_type": "text",
      "response_options": []
    },
    {
      "id": 8,
      "display_order": 8,
      "text": "If yes, please confirm your email address",
      "response_type": "text",
      "response_options": []
    },
    {
      "id": 9,
      "display_order": 9,
      "text": "If yes, please confirm your phone number",
      "response_type": "text",
      "response_options": []
    },
    {
      "id": 10,
      "display_order": 10,
      "text": "So we can report back on your potential savings, what type of heating system do you have? (Across the whole home, not just in individual rooms)",
      "response_type": "radio",
      "response_options": [
        "Forced hot air – vents",
        "Radiators – water",
        "Radiators – steam",
        "Basebaord – water",
        "Baseboard – electric",
        "Other"
      ]
    },
    {
      "id": 11,
      "display_order": 11,
      "text": "If other, please specify",
      "response_type": "text",
      "response_options": []
    },
    {
      "id": 12,
      "display_order": 12,
      "text": "What type of heating FUEL do you use for that heating system?",
      "response_type": "radio",
      "response_options": [
        "Oil",
        "Gas",
        "Electric (for baseboard)",
        "Other"
      ]
    },
    {
      "id": 13,
      "display_order": 13,
      "text": "If other, please specify",
      "response_type": "text",
      "response_options": []
    },
    {
      "id": 14,
      "display_order": 14,
      "text": "We expect to have “heat pump coaches” available to walk through the process with you (volunteers, who are not affiliated with any installer or brand). Would you like to know more about how to get free, personal help from a heat pump coach?",
      "response_type": "radio",
      "response_options": [
        "Yes",
        "No"
      ]
    },
    {
      "id": 15,
      "display_order": 15,
      "text": "If yes, please confirm your name",
      "response_type": "text",
      "response_options": []
    },
    {
      "id": 16,
      "display_order": 16,
      "text": "If yes, please confirm your email address",
      "response_type": "text",
      "response_options": []
    },
    {
      "id": 17,
      "display_order": 17,
      "text": "If yes, please confirm your phone number",
      "response_type": "text",
      "response_options": []
    }
  ],
  "url": "http://localhost:3000/surveys/1.json"
}

* Return question text and response text in English by default, but use the headers provided by ACCEPT_LANGUAGE to pick the available language.
Copy link
Contributor

@mikelynch mikelynch left a comment

Choose a reason for hiding this comment

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

I haven't tried running this, but it looks reasonable. Would be good to sort the CI issues but otherwise 👍

backend/app/models/survey_question.rb Outdated Show resolved Hide resolved
backend/app/models/survey_question.rb Outdated Show resolved Hide resolved
mzagaja and others added 3 commits October 4, 2023 00:13
We are no longer insecure.

Co-authored-by: Linden Huhmann <[email protected]>
Co-authored-by: Mike Lynch <[email protected]>
Co-authored-by: Sunnkist <[email protected]>
* Added check for language_code
* We have to feed the language_code as an argument in order to grab the correct values.
* We only want to pull what is available.
@mikelynch mikelynch self-requested a review October 4, 2023 01:26
@mikelynch
Copy link
Contributor

Would be good to return some sort of exception if the user requests a language code we don't have a localization for.

Copy link
Member Author

@mzagaja mzagaja left a comment

Choose a reason for hiding this comment

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

Think we just need to dial-in the code for picking the language from the params and then we're good to go.

backend/app/controllers/surveys_controller.rb Show resolved Hide resolved
@aTegart aTegart self-requested a review October 18, 2023 00:38
@mzagaja mzagaja merged commit 0635239 into main Oct 18, 2023
6 checks passed
@mzagaja mzagaja deleted the 414-add-language-support branch October 18, 2023 00:41
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.

3 participants