rosskouk / asknavidrome

An Alexa skill to allow streaming of music from Subsonic API compatible media servers on Amazon Echo devices.
https://rosskouk.github.io/asknavidrome
MIT License
48 stars 7 forks source link

Provide localization capability #27

Open sonntam opened 10 months ago

sonntam commented 10 months ago

First of all, thank you for the awesome program. The manual is very easy to follow and I got it setup correctly on the first try. It's working like a charm!

As currently Alexa always utters a confirmation hard-coded in English I'd like to see some way to have localization built into the app such that e.g. via environment variable a different locale can be selected. I have no experience in doing such a thing but maybe I can help if you have a recommendation on how to implement it in a good way. Beware, my Python is sub-par ;-)

Also another useful config option could be to disable spoken confirmations altogether.

rosskouk commented 9 months ago

Hi,

Thanks for the request. It should be reasonably easy to add localisation, effectively the now hard coded strings would be replaced with variables which would reference a localisation file. That file would set the speech related strings based on the localisation set in the config.

Users would still need to manually set up the locale on their echo devices and the skill on the Amazon side. I suspect that the same setup could also disable speech altogether, I wouldn't recommend that though as it is good for troubleshooting.

If you're interested in helping with translation let me know, which languages are you interested in? Also happy to look at a pull request if you want to have a go at it too.

sonntam commented 9 months ago

@rosskouk You are right. It shouldn't be that difficult albeit non-trivial. I read a bit about Python and internationalization (= i18n) and it seems Python supports this natively via the gettext module. There are also some nicely written tutorials e.g. this one I found via Google. Unfortunately, in a quick search I couldn't find many major apps written in Python using this. Some examples are

The downside is that a whole toolchain consisting of multiple tools is necessary to create and maintain translations, i.e. pygettext, msgfmt, msgmerge. This would make some kind of build script necessary to have. I'm not quite sure what the best practice here would be. Django is using a build script in Python for that.

I personally am in need of a German translation and will of course provide one with pleasure. The Alexa Skill config JSON I already translated to German (using ChatGPT and some manual clean-up).

If the above approach using gettext appeals to you I'd like to try to contribute. For this I setup a fork with a devel_i18n branch. Along the way I'd document what steps were necessary.

Please let me know your thoughts on this. Thank you!

rosskouk commented 9 months ago

Hey @sonntam,

That sounds great, happy to include your pull request once it's ready.

andresponte commented 6 months ago

Hi @sonntam, I could also help with the translations to Spanish and Portuguese.