kas-catholic / confessit-web

Source code for https://confessit.app
MIT License
18 stars 8 forks source link

Translations Framework Suggestion #11

Closed evang522 closed 2 years ago

evang522 commented 2 years ago

Hey guys,

referencing https://github.com/kas-catholic/confessit-web/issues/6

this isn't by any means a serious or full implementation, but I could at least share with you the way that I've implemented translations in my react app chrome extension https://chrome.google.com/webstore/detail/memento/jfpnlhmdmlfbjejmnfgacgkkligneihb.

It basically just works on translation config files and a service which is initialized at the App load, which helps to build the sinsDB on app render. As I said, the ui implementation is a bit hacky in order to just quickly get a representation together, one shouldn't use 'forceUpdate' by any means.

It's definitely a more programmatic approach to translations, but I must say it works rather well for me as well as for my company.

You should be able to build the app to test it out. Cheers!

kas-catholic commented 2 years ago

Thanks for the PR! I might not have time to take a thorough look at it 'til this weekend but I'll try to get it done soon.

evang522 commented 2 years ago

@kas-catholic of course take your time :) I published a netlify page from my own repo in case it helps with the preview: https://optimistic-mayer-296ef3.netlify.app/

kas-catholic commented 2 years ago

@evang522 First of all, thank you for this PR. I appreciate your thoughts and insight, and I like the simplicity of this approach.

Your PR pushed me to take a more serious look at getting translations implemented, something I've wanted to do for a while and never got around to. I compared your suggestions here to i18next, a framework I had looked into a little bit and researched more in the past few days. I ultimately decided to move forward with i18next rather than your solution. The simplicity of your approach was a big draw for me, but after experimenting with i18next for a bit I found that it doesn't seem to introduce a burdensome amount of complexity, and I like using a well-documented library that can handle (and has probably already solved) all the complexities we might run into without additional work.

From my experimentation, I've begun implementing i18next have merged the core bits to main, though I haven't moved 100% of our strings to it yet. If you'd like to contribute to that effort, your help would be welcome - let's discuss in #6 or over Slack to avoid duplicating work. The plan will be, roughly:

evang522 commented 2 years ago

@kas-catholic Yep, I get wanting the framework build around it. I hope the implementation of i18 goes well. I will try to see if i've got some time for it sometime soon though I am a bit busy the next weeks :+1: