Skip to content

LG-6026: Telephone input country listing is not translated#6336

Merged
jc-gsa merged 10 commits intomainfrom
jc-LG-6026-translate-country-names-input
May 20, 2022
Merged

LG-6026: Telephone input country listing is not translated#6336
jc-gsa merged 10 commits intomainfrom
jc-LG-6026-translate-country-names-input

Conversation

@jc-gsa
Copy link
Contributor

@jc-gsa jc-gsa commented May 11, 2022

No description provided.

@jc-gsa jc-gsa requested review from a team and aduth May 11, 2022 15:11
Copy link
Contributor

@zachmargolis zachmargolis left a comment

Choose a reason for hiding this comment

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

LGTM

Co-authored-by: Zach Margolis <zachmargolis@users.noreply.github.com>
@jc-gsa jc-gsa force-pushed the jc-LG-6026-translate-country-names-input branch 2 times, most recently from 96c73f6 to 0439b0a Compare May 11, 2022 23:43
@jc-gsa jc-gsa force-pushed the jc-LG-6026-translate-country-names-input branch from 0439b0a to 34eaa61 Compare May 12, 2022 03:58
Copy link
Contributor

@aduth aduth left a comment

Choose a reason for hiding this comment

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

Looks good! 👍

/** @type {string[]} */
deliveryMethods = [];

/** @type {Object.<string,*>} */
Copy link
Contributor

@aduth aduth May 12, 2022

Choose a reason for hiding this comment

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

It looks to me like it works in practice, though my understanding is that it's recommended to avoid the uppercase "Object" type (along with a few others). Also, would we be safe to assume that the expected value should be a string?

Maybe one of these:

Suggested change
/** @type {Object.<string,*>} */
/** @type {Record<string, string>} */
Suggested change
/** @type {Object.<string,*>} */
/** @type {object} */

The latter comes from the DefinitelyTyped types for the library, in case we want to align to that, and optionally add it as a devDependency to our project.


try {
this.deliveryMethods = JSON.parse(this.dataset.deliveryMethods || '');
this.countryCodePairs = JSON.parse(this.dataset.translatedCountryCodeNames || '');
Copy link
Contributor

Choose a reason for hiding this comment

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

Not that I would expect it to fail, but one downside of grouping these assignments in the same try block is that if deliveryMethods fails to parse, we won't assign countryCodePairs, even if countryCodePairs could be parsed.

To me, it seems like either we should trust that they'd always parse correctly and avoid the try blocks altogether, or if we want to be guarded about it, we should have two separate try blocks, one for each.

Suggested change
this.countryCodePairs = JSON.parse(this.dataset.translatedCountryCodeNames || '');
} catch {}
try {
this.countryCodePairs = JSON.parse(this.dataset.translatedCountryCodeNames || '');

aduth added 2 commits May 12, 2022 16:54
changelog: Improvements, Phone Input, Show translated text labels for phone dropdowns
@jc-gsa jc-gsa merged commit d1ca969 into main May 20, 2022
@jc-gsa jc-gsa deleted the jc-LG-6026-translate-country-names-input branch May 20, 2022 15:58
@jc-gsa jc-gsa restored the jc-LG-6026-translate-country-names-input branch August 29, 2022 23:12
@jc-gsa jc-gsa deleted the jc-LG-6026-translate-country-names-input branch December 26, 2024 17:52
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