thombruce / toodles

✅ A super simple todo app
https://toodles.thombruce.com/
GNU General Public License v3.0
0 stars 0 forks source link

i18n #84

Closed thombruce closed 1 year ago

thombruce commented 1 year ago

Closes #27

github-actions[bot] commented 1 year ago

Coverage Summary for `./packages/web`

Status Category Percentage Covered / Total
🟢 Lines 67.93% / 60% 358 / 527
🟢 Statements 67.93% / 60% 358 / 527
🟢 Functions 63.41% / 60% 26 / 41
🟢 Branches 70.17% / 60% 40 / 57
File Coverage
File Stmts % Branch % Funcs % Lines Uncovered Lines
packages/web/src/components/ContextTag.vue 20% 100% 0% 20% 4-15
packages/web/src/components/ProgressBar.vue 70.58% 75% 100% 70.58% 8-10, 13-19
packages/web/src/components/ProjectTag.vue 20% 100% 0% 20% 4-15
packages/web/src/components/TagTag.vue 71.42% 100% 0% 71.42% 6-7
packages/web/src/components/TodoItem.vue 73.58% 40% 28.57% 73.58% 20-24, 26-27, 31-37
packages/web/src/components/TodoList.vue 73.68% 100% 100% 73.68% 11-15
packages/web/src/components/TodoPriority.vue 20% 100% 0% 20% 4-15
packages/web/src/components/TodoText.vue 65.85% 58.33% 83.33% 65.85% 15-18, 21-24, 27-28, 33-36
packages/web/src/models/Todo.ts 89.61% 75% 100% 89.61% 27-32, 46-47
packages/web/src/plugins/dexie.ts 46.29% 100% 66.66% 46.29% 21-22, 25-31, 35-54
packages/web/src/plugins/lunr.ts 78.57% 100% 0% 78.57% 10-12
packages/web/src/plugins/timepiece.ts 71.42% 60% 50% 71.42% 14-19
packages/web/src/stores/todos.ts 74.07% 90% 83.33% 74.07% 21, 25, 29-31, 35-37, 41-43, 47-49, 53-55, 59-61, 65-67, 71-73, 77-79, 83-85, 91, 95-103
thombruce commented 1 year ago

Basic stuff; we're just setting up the mechanism to permit further translations in the future. There aren't that many strings that need translating... yet.

Language should change automatically dependent on user's actual locale, but I need to test this. I think we still should probably have a button as well as this to handle manually changing language.

thombruce commented 1 year ago

For locale changing see: https://vue-i18n.intlify.dev/guide/essentials/scope.html

thombruce commented 1 year ago

With a mechanism to change language implemented and defaulting to 'en' if an unsupported language is present... this is now done.

Some of the logic may need reworked later. For instance if we add support for sub-languages like 'en-US' and 'en-GB', then the default selector will need to be tweaked. And naturally we need to add support for other languages... but this should be easy for contributors to do at this point - I don't speak much any language other than English, but the mechanism is there to support whatever language gets added; the contributor just needs to do two things:

  1. Add a i18n/[lang].ts file (e.g. i18n/en.ts)
  2. Add it to the exports list in i18n/index.ts

I think that's as minimal as I can make the process without stuffing all translations into a single file. This is preferable to that. Two simple changes, and I am more than happy to handle the second part for anyone not too familiar with programming if it means they're contributing their language to the project.

In fact... I could create an application that makes this kind of contribution SUPER easy. It'd be a wholly separate project, but I might consider it as it might have some other utilities too... The idea being that it would be a non-programming way for non-programmers to contribute... strings, I guess. I don't know what use that has outside of internationalisation, but I'll keep the idea in mind.