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

fix: localize attributes properly #2016

Merged
merged 24 commits into from
Dec 6, 2023
Merged

Conversation

chosww
Copy link
Collaborator

@chosww chosww commented Nov 28, 2023

Resolves #2011.

Prerequisites

If this PR changes PHP code or dependencies:

  • I've run composer format and fixed any code formatting issues.
  • I've run composer analyze and addressed any static analysis issues.
  • I've run php artisan test and ensured that all tests pass.
  • I've run composer localize to update localization source files and committed any changes.

If this PR changes CSS or JavaScript code or dependencies:

  • I've run npm run lint and fixed any linting issues.
  • I've run npm run build and ensured that CSS and JavaScript assets can be compiled.

@chosww chosww added the bug Something isn't working label Nov 28, 2023
@chosww chosww self-assigned this Nov 28, 2023
@chosww
Copy link
Collaborator Author

chosww commented Nov 28, 2023

@jobara I think the meeting types error is the one like UpdateProjectRequest; the ones don't use :attribute explicitly. I didn't find any use cases of :attribute for meeting_types, could you tell me in which workflow you got that error message please?

@chosww chosww requested a review from jobara November 28, 2023 22:43
Copy link

codecov bot commented Nov 28, 2023

Codecov Report

Attention: 14 lines in your changes are missing coverage. Please review.

Comparison is base (4d59c59) 97.65% compared to head (7bb3abf) 97.62%.

❗ Current head 7bb3abf differs from pull request most recent head 6dd8016. Consider uploading reports for the commit 6dd8016 to get more accurate results

Files Patch % Lines
app/Http/Requests/StoreDefinedTermRequest.php 0.00% 7 Missing ⚠️
app/Http/Requests/UpdateDefinedTermRequest.php 0.00% 7 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##                dev    #2016      +/-   ##
============================================
- Coverage     97.65%   97.62%   -0.03%     
- Complexity     2055     2103      +48     
============================================
  Files           314      314              
  Lines          8991     9481     +490     
============================================
+ Hits           8780     9256     +476     
- Misses          211      225      +14     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jobara
Copy link
Collaborator

jobara commented Nov 29, 2023

@jobara I think the meeting types error is the one like UpdateProjectRequest; the ones don't use :attribute explicitly. I didn't find any use cases of :attribute for meeting_types, could you tell me in which workflow you got that error message please?

I believe it's coming from the validation.required text. It's likely the case that a required meeting_types field is empty. An example would be from UpdateIndividualCommunicationAndConsultationPreferencesRequest validation.

My feeling at the moment is that any validated field should have a localized attribute name specified. This would prevent errors if we removed an overridden message, or didn't override one that became needed later (e.g. changed the validation rules).

@jobara
Copy link
Collaborator

jobara commented Nov 30, 2023

Tests will be expanded with #1813

@jobara
Copy link
Collaborator

jobara commented Nov 30, 2023

@chosww could you please run php artisan localize and commit the updates?

Copy link
Collaborator

@jobara jobara left a comment

Choose a reason for hiding this comment

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

It looks like you missed doing AcceptInvitationRequest. It looks like the only attribute there is email.

Comment on lines 24 to 29
public function attributes(): array
{
return [
'roles' => __('roles'),
];
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
public function attributes(): array
{
return [
'roles' => __('roles'),
];
}
public function attributes(): array
{
return [
'roles' => __('roles'),
'roles.*' => __('roles'),
];
}

public function attributes(): array
{
return [
'locale' => __('locale'),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
'locale' => __('locale'),
'locale' => __('website language'),

Comment on lines 37 to 42
public function attributes(): array
{
return [
'roles' => __('You must select what you would like to do on the website.'),
];
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

It looks like you copied the message here instead of adding the attribute value.

Suggested change
public function attributes(): array
{
return [
'roles' => __('You must select what you would like to do on the website.'),
];
}
public function attributes(): array
{
return [
'roles' => __('roles'),
'roles.*' => __('roles'),
];
}

Comment on lines 113 to 129
'start_time' => __('meeting start time'),
'end_time' => __('meeting end time'),
'date' => __('meeting date'),
'directions' => __('directions'),
'timezone' => __('meeting time zone'),
'locality' => __('city or town'),
'region' => __('province or territory'),
'meeting_url' => __('link to join the meeting'),
'meeting_phone' => __('phone number to join the meeting'),
'meeting_software' => __('meeting software'),
'alternative_meeting_software' => __('alternative meeting software'),
'additional_video_information' => __('additional video information'),
'additional_phone_information' => __('additional phone information'),
'meeting_types' => __('meeting types'),
'street_address' => __('Street address'),
'postal_code' => __('Postal code'),
'unit_suite_floor' => __('Unit, suite, or floor'),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
'start_time' => __('meeting start time'),
'end_time' => __('meeting end time'),
'date' => __('meeting date'),
'directions' => __('directions'),
'timezone' => __('meeting time zone'),
'locality' => __('city or town'),
'region' => __('province or territory'),
'meeting_url' => __('link to join the meeting'),
'meeting_phone' => __('phone number to join the meeting'),
'meeting_software' => __('meeting software'),
'alternative_meeting_software' => __('alternative meeting software'),
'additional_video_information' => __('additional video information'),
'additional_phone_information' => __('additional phone information'),
'meeting_types' => __('meeting types'),
'street_address' => __('Street address'),
'postal_code' => __('Postal code'),
'unit_suite_floor' => __('Unit, suite, or floor'),
'title.en' => __('meeting title (English)'),
'title.fr' => __('meeting title (French)'),
'title.*' => __('meeting title'),
'start_time' => __('meeting start time'),
'end_time' => __('meeting end time'),
'date' => __('meeting date'),
'directions' => __('directions'),
'timezone' => __('meeting time zone'),
'locality' => __('city or town'),
'region' => __('province or territory'),
'meeting_url' => __('link to join the meeting'),
'meeting_phone' => __('phone number to join the meeting'),
'meeting_software' => __('meeting software'),
'alternative_meeting_software' => __('alternative meeting software'),
'additional_video_information' => __('additional video information'),
'additional_phone_information' => __('additional phone information'),
'meeting_types' => __('ways to attend'),
'meeting_types.*' => __('ways to attend'),
'street_address' => __('Street address'),
'postal_code' => __('Postal code'),
'unit_suite_floor' => __('Unit, suite, or floor'),

@@ -28,4 +28,12 @@ public function rules()
'definition.*' => 'nullable|string',
];
}

public function attributes(): array
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think this file is used anymore. I think we can delete it. Can you confirm?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It doesn't seems like it, though I think this may be used later? We should confirm with @greatislander

Comment on lines 123 to 124
'service_areas' => __('Service areas'),
'sectors' => __('Sectors'),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
'service_areas' => __('Service areas'),
'sectors' => __('Sectors'),
'service_areas' => __('Service areas'),
'service_areas.*' => __('Service areas'),
'sectors' => __('type of Regulated Organization'),

'about.fr' => __('"About your organization" (French)'),
'about.en' => __('"About your organization" (English)'),
'accessibility_and_inclusion_links.*.title' => __('accessibility and inclusion link title'),
'accessibility_and_inclusion_links.*.url' => __('accessibility and inclusion link'),
'social_links.*.active_url' => __(''),
'social_links' => __('Social media links'),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
'social_links' => __('Social media links'),
'social_links.*' => __('Social media links'),

'contact_person_name' => __('Contact person'),
'contact_person_email' => __('Contact person’s email'),
'contact_person_phone' => __('Contact person’s phone number'),
'contact_person_vrs' => __('Contact person’s vrs'),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
'contact_person_vrs' => __('Contact person’s vrs'),
'contact_person_vrs' => __('Contact person requires Video Relay Service (VRS) for phone calls'),

public function attributes(): array
{
return [
'theme' => __('Theme'),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
'theme' => __('Theme'),
'theme' => __('Contrast adjustment'),

@chosww chosww requested a review from jobara December 1, 2023 21:14
@jobara jobara added this to the 1.2.4 milestone Dec 4, 2023
@jobara
Copy link
Collaborator

jobara commented Dec 4, 2023

It looks like you missed doing AcceptInvitationRequest. It looks like the only attribute there is email.

I think this one is still missing. It's being done through withValidator().

@chosww
Copy link
Collaborator Author

chosww commented Dec 4, 2023

@jobara this PR is ready for another review, thanks!

@jobara jobara modified the milestones: 1.2.4, 1.2.5 Dec 4, 2023
Copy link
Collaborator

@jobara jobara left a comment

Choose a reason for hiding this comment

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

@chosww could you also re-run composer localize?

app/Http/Requests/DestroyUserRequest.php Show resolved Hide resolved
public function attributes(): array
{
return [
'email' => __('email address'),
Copy link
Collaborator

Choose a reason for hiding this comment

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

I notice in at least one other location that we've used __('email') instead. If it makes sense, can we make these consistent?

Comment on lines 35 to 36
'name.en' => __('organization name (English)'),
'name.fr' => __('organization name (French)'),
Copy link
Collaborator

Choose a reason for hiding this comment

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

These don't appear to be required here. Perhaps they were added to the wrong file.

Comment on lines 35 to 36
'term' => __('term'),
'definition' => __('definition'),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Missing 'term.*' and 'definition.*'.

@chosww chosww requested a review from jobara December 5, 2023 14:45
@chosww chosww requested a review from jobara December 5, 2023 19:06
Copy link
Collaborator

@jobara jobara left a comment

Choose a reason for hiding this comment

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

@chosww could you please run composer localize again. I think that's all that's left.

@jobara jobara enabled auto-merge (squash) December 6, 2023 14:04
@jobara jobara self-requested a review December 6, 2023 14:04
@jobara jobara merged commit fbd95be into accessibility-exchange:dev Dec 6, 2023
6 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Attribute names in validation messages are not localized
2 participants