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

first pass at using message variants #483

Merged
merged 5 commits into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ public static ArrayList<LinkedHashMap> formattedHouseholdData(Submission submiss
LinkedHashMap user = new LinkedHashMap();
if (id.equals("you")) {
user.put("uuid", id);
user.put("firstName", inputData.get("firstName") + " (you)");
user.put("firstNamePossessive", inputData.get("firstName") + "'s (your)");
user.put("firstName", inputData.get("firstName"));

householdDataObject.add(user);
} else {
Expand All @@ -60,7 +59,6 @@ protected static LinkedHashMap householdData(ArrayList<LinkedHashMap> household,
if (hhmember.get("uuid").equals(uuid)) {
user.put("uuid", uuid);
user.put("firstName", hhmember.get("householdMemberFirstName"));
user.put("firstNamePossessive", hhmember.get("householdMemberFirstName")+ "'s");
continue;
}
}
Expand Down
8 changes: 6 additions & 2 deletions src/main/resources/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -546,8 +546,10 @@ school-who.header=Who is going to school?
schooldetails.title=School Details
schooldetails.header=We need some additional details.
schooldetails.subheader=An asterisk (*) indicates a required field.
schooldetails.formquestion1=* What is the name of {0} school?
schooldetails.formquestion1.posessive=* What is the name of your ({0}\u2019s) school?
schooldetails.formquestion1=* What is the name of {0}\u2019s school?
schooldetails.formquestion2=* How often does {0} go to school?
schooldetails.formquestion2.posessive=* How often do you ({0}) go to school?
schooldetails.question2-helptext=The number of hours considered as half-time enrollment is determined by the institution of higher education.
schooldetails.fulltime=Full-time
schooldetails.halftime=Half-time
Expand All @@ -561,7 +563,8 @@ pregnancy-who.header=Who is pregnant?
pregnantduedate.title=Pregnancy Due Date
pregnantduedate.header=Pregnancy Due Date
pregnantduedate.subheader=</br>An estimate is ok.</br></br>Month / Day / Year
pregnantduedate.question=When is {0} due date?
pregnantduedate.question=When is {0}\u2019s due date?
pregnantduedate.question.posessive=When is your ({0}\u2019s) due date?

# Out of state benefits
out-of-state-benefits.title=Out of state benefits
Expand Down Expand Up @@ -668,6 +671,7 @@ personal-situations-who.header=Who has a personal situation that makes it hard t

personal-situations-which.title=Which Personal Situations
personal-situations-which.subheader=Which personal situations apply to {0}?
personal-situations-which-you.subheader=Which personal situations apply to {0} (you)?
personal-situations.which.option1=Being homeless
personal-situations.which.option2=Struggling with drugs or alcohol
personal-situations.which.option3=Experiencing domestic abuses
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
<th:block th:ref="formContent">

<div class="form-card__content">
<div th:each="individual, iter: ${inputData.get('pregnanciesFullNames[]')}" class="spacing-below-15">
<div th:each="individual, iter: ${inputData.get('pregnanciesFullNames[]')}" class="spacing-below-15" th:with="messageVariant=${individual.uuid == 'you' ? 'self' : 'householdMember'}">
lkemperman-cfa marked this conversation as resolved.
Show resolved Hide resolved
<th:block th:with="pregnancyDueDateInputName=${'PregnancyDueDate' + T(formflow.library.inputs.FieldNameMarkers).DYNAMIC_FIELD_MARKER + individual.uuid}">
<th:block th:replace="~{fragments/inputs/duedate ::
duedate(inputName=${pregnancyDueDateInputName},
label=#{pregnantduedate.question(${individual.firstNamePossessive})},
label=${messageVariant == 'self' ? #messages.msgWithParams('pregnantduedate.question.posessive', individual.firstName) : #messages.msgWithParams('pregnantduedate.question', individual.firstName)},
groupHelpText=#{pregnantduedate.subheader},
groupName='PregnancyDueDate')}"/>
</th:block>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
<th:block th:replace="'fragments/form' :: form(action=${formAction}, content=~{::formContent})">
<th:block th:ref="formContent">
<div class="form-card__content">
<div th:each="individual, iter: ${inputData.get('studentsFullNames[]')}" class="spacing-below-15">
<div th:each="individual, iter: ${inputData.get('studentsFullNames[]')}" class="spacing-below-15" th:with="messageVariant=${individual.uuid == 'you' ? 'self' : 'householdMember'}">
<th:block th:with="schoolNameInputName=${'schoolName' + T(formflow.library.inputs.FieldNameMarkers).DYNAMIC_FIELD_MARKER + individual.uuid}">
<th:block th:replace="~{'fragments/inputs/text' ::
text(inputName=${schoolNameInputName},
label=#{schooldetails.formquestion1(${individual.firstNamePossessive})})}"/>
label=${messageVariant == 'self' ? #messages.msgWithParams('schooldetails.formquestion1.posessive', individual.firstName) : #messages.msgWithParams('schooldetails.formquestion1', individual.firstName)})}"/>
</th:block>
<th:block th:with="schoolEnrollmentInputName=${'schoolEnrollmentLevel' + T(formflow.library.inputs.FieldNameMarkers).DYNAMIC_FIELD_MARKER + individual.uuid}">
<th:block
th:replace="~{fragments/inputs/radioFieldset :: radioFieldset(label=#{schooldetails.formquestion2(${individual.firstName})}, inputName=${schoolEnrollmentInputName}, fieldsetHelpText=#{schooldetails.question2-helptext}, content=~{::schoolEnrollmentLevels})}">
th:replace="~{fragments/inputs/radioFieldset :: radioFieldset(label=${messageVariant == 'self' ? #messages.msgWithParams('schooldetails.formquestion2.posessive', individual.firstName) : #messages.msgWithParams('schooldetails.formquestion2', individual.firstName)}, inputName=${schoolEnrollmentInputName}, fieldsetHelpText=#{schooldetails.question2-helptext}, content=~{::schoolEnrollmentLevels})}">
<th:block th:ref="schoolEnrollmentLevels">
<th:block th:replace="~{fragments/inputs/radio :: radio(value=#{schooldetails.fulltime}, label=#{schooldetails.fulltime})}"/>
<th:block th:replace="~{fragments/inputs/radio :: radio(value=#{schooldetails.halftime}, label=#{schooldetails.halftime})}"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
<th:block th:replace="~{'fragments/inputs/checkboxFieldset' ::
checkboxFieldset(inputName='personalSituationsListed',
ariaLabel='header',
content=~{::whichPersonalSituations})}">
content=~{::whichPersonalSituations})}"
th:with="messageVariant=${individual.uuid == 'you' ? 'self' : 'householdMember'}">
<th:block th:ref="whichPersonalSituations">
<h2 th:text="#{personal-situations-which.subheader(${individual.firstName})}"></h2>
<h2 th:text="${messageVariant == 'self' ? #messages.msgWithParams('personal-situations-which-you.subheader', individual.firstName) : #messages.msgWithParams('personal-situations-which.subheader', individual.firstName)}"></h2>
<p th:text="#{general.check-all-that-apply}"></p>
<th:block
th:replace="~{'fragments/inputs/checkboxInSet' :: checkboxInSet(inputName='personalSituationHomelessSwitch',value=${individual.uuid}, label=#{personal-situations.which.option1})}"/>
Expand Down