snapdrop-android icon indicating copy to clipboard operation
snapdrop-android copied to clipboard

[website UI] Fully localize all toasts and dialogs

Open fm-sys opened this issue 4 years ago • 12 comments

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_

fm-sys avatar Apr 11 '21 21:04 fm-sys

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

ueen avatar Apr 23 '21 16:04 ueen

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).

fm-sys avatar Apr 23 '21 17:04 fm-sys

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...

ueen avatar Apr 23 '21 18:04 ueen

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...

fm-sys avatar Apr 23 '21 18:04 fm-sys

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..

ueen avatar Apr 23 '21 22:04 ueen

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...

fm-sys avatar Apr 24 '21 09:04 fm-sys

Yea that would work but I'd prefer a compatible js version, is there no crowd translation solution that might work?

ueen avatar Apr 24 '21 09:04 ueen

It's pretty much json that might work with gitlocalize, no?

ueen avatar Apr 24 '21 10:04 ueen

These are the supported file formats: https://support.crowdin.com/supported-formats/

fm-sys avatar Apr 24 '21 10:04 fm-sys

Looks good, it does say js there, let's see if we can set this up :)

ueen avatar Apr 24 '21 17:04 ueen

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)

fm-sys avatar Feb 28 '22 00:02 fm-sys

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)

artelse avatar Mar 16 '24 22:03 artelse