Skip to content

Commit

Permalink
Exit Survey i18n (#97)
Browse files Browse the repository at this point in the history
* Rename exit survey file

* Move exit json data to templates

* Replace exit survey's text with translation keys

* Incorporate node lts v22.x

* Update dependencies

* Add locale parameter and move survey text code to templates

* Remove unneeded file

* Update tests

* Add function to index

* These functions don't need to be exported

* Add conditional for choices element

* Update exit survey for tests and add tests

* Github actions doesn't support v22 just yet.

* Update to package lock

* Fix test issue were v18 doesn't like "Object.defineProperty"

* Changeset

* SurveyJS locale (#98)

* Remove unneeded survey-jquery package

* Set surveyJS locale

* Update plugin with new survey function

* Remove print statement

* Add tests for SurveyJS locale

* Changeset

* Add locale to consent survey

* Update tests
  • Loading branch information
okaycj authored Nov 4, 2024
1 parent bbdac4a commit c678107
Show file tree
Hide file tree
Showing 20 changed files with 491 additions and 518 deletions.
5 changes: 5 additions & 0 deletions .changeset/khaki-bobcats-pump.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@lookit/surveys": patch
---

Set SurveyJS Locale to trial's locale parameter.
6 changes: 6 additions & 0 deletions .changeset/shy-cobras-flow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@lookit/templates": patch
"@lookit/surveys": patch
---

Add localization to the exit survey trial
77 changes: 29 additions & 48 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions packages/record/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,7 @@
"@rollup/plugin-image": "^3.0.3",
"@rollup/plugin-replace": "^6.0.1",
"@types/audioworklet": "^0.0.60",
"@types/js-yaml": "^4.0.9",
"@types/node-polyglot": "^2.5.0",
"handlebars": "^4.7.8",
"i18next": "^23.15.1",
"i18next-icu": "^2.3.0",
"js-yaml": "^4.1.0",
"rollup-plugin-dotenv": "^0.5.1",
"rollup-plugin-polyfill-node": "^0.13.0",
"rollup-plugin-string-import": "^1.2.4",
Expand Down
4 changes: 2 additions & 2 deletions packages/surveys/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@
"dependencies": {
"@jspsych/plugin-survey": "^2.0.0",
"dompurify": "^3.0.11",
"marked": "^12.0.1",
"survey-jquery": "^1.9.136"
"marked": "^12.0.1"
},
"devDependencies": {
"@jspsych/config": "^2.0.0",
"@types/dompurify": "^3.0.5"
},
"peerDependencies": {
"@lookit/data": "^0.1.0",
"@lookit/templates": "^1.0.0",
"jspsych": "^8.0.2"
}
}
17 changes: 14 additions & 3 deletions packages/surveys/src/consentSurvey.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
import SurveyPlugin from "@jspsych/plugin-survey";
import { TrialType } from "jspsych";
import { ParameterType, TrialType } from "jspsych";
import { consentSurveyFunction } from "./utils";

type Info = typeof SurveyPlugin.info;
const info = <const>{
...SurveyPlugin.info,
parameters: {
...SurveyPlugin.info.parameters,
locale: {
type: ParameterType.STRING,
default: "en-us",
},
},
};

type Info = typeof info;
export type Trial = TrialType<Info>;

/** Consent Survey plugin extends jsPsych's Survey Plugin. */
Expand All @@ -18,7 +29,7 @@ export class ConsentSurveyPlugin extends SurveyPlugin {
public trial(display_element: HTMLElement, trial: Trial) {
super.trial(display_element, {
...trial,
survey_function: consentSurveyFunction(trial.survey_function),
survey_function: consentSurveyFunction(trial),
});
}
/**
Expand Down
7 changes: 7 additions & 0 deletions packages/surveys/src/errors.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/** Error thrown when trial is expecting locale parameter and on is not found. */
export class TrialLocaleParameterUnset extends Error {
/** This will show when the locale is not set in a trial. */
public constructor() {
super("Locale not set in trial parameters.");
}
}
132 changes: 0 additions & 132 deletions packages/surveys/src/exit.spec.ts

This file was deleted.

Loading

0 comments on commit c678107

Please sign in to comment.