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

121 - Add locale functionality and locale mixin #255

Merged
merged 24 commits into from
Jul 21, 2021
Merged

Conversation

tmcconechy
Copy link
Member

@tmcconechy tmcconechy commented Jul 14, 2021

Explain the details for making this change. What existing problem does the pull request solve?

This PR adds locale from 4.x but makes some improvements namely:

  • works with async
  • a lot less code and used more browser apis (number.toLocaleString and Intl.DateTimeFormat)

In addition added some locale features to some but not all components:

  • ids-text can translate
  • ids-data-grid can format cells
  • some RTL conversion
  • ids-icon can flip directional icons

This should have most of what we need to move forward.

In addition:

  • found more places in text to change properties to attributes

Related github/jira issue (required):
Closes #121

Steps necessary to review your pull request (required):
Translations

Misc

Datagrid Formatters

  • go to http://localhost:4300/ids-data-grid
  • on the container or ids-data-grid change locale to de-DE and see that the numbers and dates change in the grid
  • on the container or ids-data-grid change language to ar and see that it works RTL

RTL

Included in this Pull Request:

  • An e2e or functional test for the bug or feature.
  • [x ] A note to the change log.

@tmcconechy tmcconechy requested a review from a team as a code owner July 14, 2021 20:01
Copy link
Contributor

@rob2d rob2d left a comment

Choose a reason for hiding this comment

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

@tmcconechy this was a really large PR but from what I can tell the patterns/approach/etc in the context of what we have are really nice!

Hopefully I did not miss anything in reviewing but I put some comments that are mostly just minor where I could.

Again though looks really great for a first PR in the WCs with this and this is a pretty big feature handled this extensively at once 👏

src/ids-mixins/README.md Outdated Show resolved Hide resolved

```js
// Respond to parent changing language
Copy link
Contributor

Choose a reason for hiding this comment

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

kind of minor but it seems this should be languagechange? (just from the recent switch to present tense to match DOM)

Copy link
Member Author

Choose a reason for hiding this comment

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

good catch

@@ -0,0 +1,5 @@
// Ids is a JavaScript project, but we define TypeScript declarations so we can
// confirm our code is type safe, and to support TypeScript users.

Copy link
Contributor

Choose a reason for hiding this comment

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

seems there's props missing on the def but not sure if it's needed since it's an MVP and we haven't tested thoroughly with TS yet.

test/ids-text/ids-text-func-test.js Outdated Show resolved Hide resolved
test/ids-text/ids-text-func-test.js Outdated Show resolved Hide resolved
src/ids-locale/TODO.md Outdated Show resolved Hide resolved
@@ -0,0 +1,1783 @@
/**
* @jest-environment jsdom
Copy link
Contributor

Choose a reason for hiding this comment

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

for first iteration these tests are really nice/simple/readable. Just for consideration though: it seems like it's quite a lot of repeating similar calls, so was thinking it could be good in future iteration to have a lookup map if that isn't convenient now? e.g. maps of Map<String, Set<String>> with Map<'en' => {'AU', 'GB','IN', 'NZ', 'US', ...}>`

Could make it a little easier to add to or change as well but this also depends on the frequency that clients request changes to this sort of thing here (which I'm not familiar enough to weigh in on).

Copy link
Member Author

Choose a reason for hiding this comment

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

I might have to add this for "validating its only in the accepted list in the future. But i think i'll punt on this for now. I sort of tried to have it "open". Although that might not totally make sense in the future. WIll keep this one in mind.

@tmcconechy
Copy link
Member Author

@rob2d made changes for all your comments. Good catches. (except i skipping the last one for now)

Copy link
Contributor

@rob2d rob2d left a comment

Choose a reason for hiding this comment

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

Changes look good @tmcconechy ! (approved)

Copy link
Contributor

@EdwardCoyle EdwardCoyle left a comment

Choose a reason for hiding this comment

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

Looks really nice @tmcconechy!

@tmcconechy tmcconechy merged commit 81fec57 into main Jul 21, 2021
@tmcconechy tmcconechy deleted the 5037-locale branch July 21, 2021 16:55
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.

IdsLocale: Add new mixin
3 participants