LonamiWebs / Stringlate

Android application to help in strings.xml translation
https://lonamiwebs.github.io/stringlate/index
MIT License
106 stars 48 forks source link

Bug: wants to translate Strings with the translate=false attribute #179

Closed Vankog closed 6 years ago

Vankog commented 6 years ago

I'm coming to you, because on https://github.com/AdAway/AdAway we are getting several translation PRs created with Stringlate that want to translate strings that are not meant to be translated. Doing some research on why this happens, I tested out your app and found that it offers to translate all strings that have the translate=false attribute (Transifex syntax). This is obviously not correct.

See, we have the problem that your users try to translate these two files over and over again: https://github.com/Vankog/AdAway/blob/master/AdAway/src/main/res/values/strings_static.xml https://github.com/Vankog/AdAway/blob/master/AdAway/src/main/res/values/strings_preferences.xml

Funny enough: While the _def tags with the format & type attributes and no assigned translate attribute are not offered for translation (which is correct here), the _key tags with the assigned translate=false attribute are offered for translation.

Stringlate recognizes that AdAway is using (or "might use") Transifex, but why isn't it just using the Transifex config file as well? The config clearly states which files should be translated and the translate=false attribute also helps. I had a glimpse into your code and you currently only seem to look for the translatable=false attribute and "do not translate" filenames instead. I know you can't support all translation tools, but their configs and syntaxes might be really helpful for your app. Otherwise it will always lead to confusion.

gsantner commented 6 years ago

Stringlate does that support as stated above very well, but only with translatable. Thats what should be used for untranslateable strings - see android docs https://developer.android.com/studio/write/translations-editor.html#untranslatable.

No, stringlate only tries to guess if some else translation service is used, but it won't interact in any with it. (Just info text)

Lonami commented 6 years ago

@gsantner translatable* IIRC.

gsantner commented 6 years ago

fine, typo in it, haha

Lonami commented 6 years ago

Anyway we could support translate, translatable and maybe even translateable? Shouldn't be an issue.

gsantner commented 6 years ago

yep of course, just currently checking if android studio is supporting some different option too

EDIT: ok so on Android Studio the only support one is the official translatable too. grafik

It too only suggests that one.

grafik

Is there no way to set the attribute in transifex? Or maybe replace it via e.g. `sed´ after pulling from transifex. This way it's complaint and can be translated via android studio too (without un-translatable strings). (Adding support for other tags in stringlate is a different thing (and doable of course), just noting that it does not solve the real problem)

Vankog commented 6 years ago

@gsantner I had a hunch that "translate" should really be "translatable". This part of the code is there since 2012 and doing some google search only showed me thousands of projects using "translate" as well. So if this is an error, it is a widespread one. Therefore, it is at least worth a look to add this case to Stringlate. ;-) I have a look if we should change it in our project, nonetheless.

I understand that you do not interact with external translation services. That is not what I intended. I am just suggesting you utilize any configs that are already there instead of trying to look for resources yourself all the time. I mean: reading the .tx/config file seems more of a help to me, because everything you are looking up and guessing for is already there: https://github.com/AdAway/AdAway/blob/master/.tx/config

I think other translations services have similar configurations you could utilize for yourself. It'll help improving Stringlate massively, just by parsing some common config files. And it will drop the frustration for the repo owners.

Vankog commented 6 years ago

Thanks :-)