[website UI] Fully localize all toasts and dialogs
The website will currently always occur in English. Only settings, etc. are localized. We maybe should try to change this in new versions. Contributions welcome ;)
Also posted by @fm-sys in https://github.com/fm-sys/snapdrop-android/issues/43#issuecomment-817375635_
I wrote a js object solution for different languages recently here https://github.com/manucaralmo/GlowCookies proabably this should be integrated to snapdrop itself or injected via js, could be the same code then in case RobinLinus wants to KISS.
Anyway, we could use window.navigator.language* to get the language, give it to the language object (s. link) and adjust accordingly, let me know if i should set this up in JSI, but maybe we should ask first wheter it can be integrated in snapdrop directly.
*https://stackoverflow.com/questions/6547642/get-the-language-of-user-in-android
Yes, doing that in the original snapdrop repository would be the best solution. Unfortunately @RobinLinus seems to be quite busy if full localisation will work over long term. Anyway, if we want to go that way Snapdrop should use a localization tool like crowdin as we use for this repo (with automatic merge preferred).
Take a look at the commit above, the way I set it up, it's completely drop in compatible with snapdrop. Yea do you want to look at how this might be integrated with crowdin? The translations are just in associative array inside a js class...
We would need some kind of folder structure (one file for every language). AFAIK crowdin unfortunately doesn't support localization for arrays inside a single file. But let's wait for some feedback at the Snapdrop repository...
Ok hmm so the for js its the easiest to have it in a js file because otherwise you would need to do xhr requests, which takes some extra time. Maybe there's another tool, do you know GitLokalize or something like that. I wouldn't count on any comments from snapdrop, I could understand why they would like to keep it simple with English only..
If we want to implement a solution only for the android app, we could rather use the strings.xml resource file which can be translated and injected easily via the JSI.
Something like this
String jsCommand = "document.querySelector(...).text=" + context.getString(R.strings.the_string_resources);
Maybe with additional escaping of special characters in the resource strings...
Yea that would work but I'd prefer a compatible js version, is there no crowd translation solution that might work?
It's pretty much json that might work with gitlocalize, no?
These are the supported file formats: https://support.crowdin.com/supported-formats/
Looks good, it does say js there, let's see if we can set this up :)
I've created a first version, see 05da35c. It uses the android resources, which seems like the easiest solution to me... (I couldn't figure out how crowdin works with js)
On my android Chinese version with language set to English, the pairdrop page shows in Chinese, while the settings are correctly displayed in English. The website in the browser allows to set the language manually. Can this be added or is there another fix? (Running version 2.2.4)