synacor / preact-i18n

Simple localization for Preact.
BSD 3-Clause "New" or "Revised" License
205 stars 18 forks source link

Use new `createContext`, remove `getChildContext`. Add `useText` hook. #42

Closed pl12133 closed 4 years ago

pl12133 commented 4 years ago

Resolves https://github.com/synacor/preact-i18n/issues/41 and https://github.com/synacor/preact-i18n/issues/39.

This continues the upgrade to Preact X, moving away from legacy context into new context.

This will maintain the same interface while converting from legacy context to createContext. However this will be a breaking change in the case of directly accessing this.context.intl which will now be undefined.

IrregularShed commented 4 years ago

@pl12133 Hi Peter, have you got any further with this? I'd like to help in any way I can to get this over the line.

jliebrand commented 4 years ago

+1 would love to see preact-i18n working with preactX

pl12133 commented 4 years ago

I'm glad to hear this PR is in demand! I'm going to take a look at the test cases today and once they pass this should be ready to merge and release as a beta.

It would be super helpful if people could check out this branch and try it in their own projects, and also try out the new useText hook and see if any bugs come up.

pl12133 commented 4 years ago

Old and new tests are passing, this should be ready for review.

If anyone could try this out in their own applications and let us know about any issues that would be very helpful.

IrregularShed commented 4 years ago

@pl12133 As soon as I get a chance to, I'll give it a try. At the moment I've found myself having to use i18next to keep the powers that be happy but I'll branch off an earlier commit and see how it goes.