grammyjs / i18n

Internationalization for grammY powered by Fluent.
https://grammy.dev/plugins/i18n
MIT License
31 stars 6 forks source link

Allow splitting translations #52

Closed strbit closed 2 months ago

strbit commented 2 months ago

Closes #51

As explained in the issue referenced above, sometimes it becomes too difficult to maintain translation files for a project and currently the library does not allow files to be split into different directories or files.

This pull-request implements this feature by walking every .ftl file in the locales directory, reading it, and merging it with any other translation it finds for that locale. This might not be the best way of implementing this feature... but it works. It also works with the standard translation layout currently implemented, which means users can use both types of layouts at once.

As of writing this, I haven't discovered anything that would be broken by this pull-request, please do let me know if it does in fact cause breaking changes or if any issues were discovered.

KnorpelSenf commented 2 months ago

I'll try to review this tonight

strbit commented 2 months ago

@KnorpelSenf I've changed the makeTempLocalesDir utility function so that it creates a couple of split translations for other tests to use, if you had a different idea in mind for what tests to add, please let me know and I'll try to implement them.

strbit commented 2 months ago

Thanks for merging the pull-request, are there any details on when the new version will be released?

KnorpelSenf commented 2 months ago

@rojvv said he wanted to do it “later” … I believe that means it'll happen today at some point. If that doesn't happen, feel free to ping me again

strbit commented 2 months ago

Alright, no worries if it takes a couple of days.

rojvv commented 2 months ago

Available in 1.1.0.

strbit commented 2 months ago

Apologies if I'm misunderstanding something, but was this version released correctly? I just tried to upgrade and I got a lot of errors. I looked at the source on NPM and saw that there is no src folder.

folder

rojvv commented 2 months ago

Apologies for the inconvenience. 1.1.2 should work.

strbit commented 2 months ago

Works as expected, thanks!