scribe-org / Scribe-Android

Android app with keyboards for language learners
GNU General Public License v3.0
27 stars 14 forks source link

Make all application strings be referenced from a Scribe-i18n XML file #44

Closed andrewtavis closed 4 weeks ago

andrewtavis commented 1 month ago

Terms

Description

Prior to release with multiple localizations, and to make it easier for people to use the exact strings that are needed for the application, it would be good to have them all be referenced from a common XML file. This file would be generated in the Scribe-i18n project whenever there's a PR from Weblate and then transferred over to Scribe-Android :)

Contribution

Would be happy to discuss and support this as well as review! 😊

andrewtavis commented 1 month ago

@angrezichatterbox, would this one make sense now? You could do a PR for some Python for https://github.com/scribe-org/Scribe-i18n/issues/27 where you'd make the XML equivalent of the xcstrings to json scripts, and then from there we can start using the XML files and don't need to worry about putting them all in later on?

angrezichatterbox commented 1 month ago

Yes, I would work on this issue. I would work on writing Python scripts for JSON to XML and XML to JSON as well and make a PR for that.

angrezichatterbox commented 1 month ago

I don't have much idea about how localization is in iOS. But I haven't seen a single strings.xml file for all the languages in any Android project yet. So could I put each language into its own XML or should I look into having a single strings.xml file for all languages? Should I make the discussions over there in the issue ?

andrewtavis commented 1 month ago

Will quote you over there, @angrezichatterbox :)

andrewtavis commented 1 month ago

Ok, @angrezichatterbox, Scribe-i18n is now in the repo at main/app/src/main/res/i18n. Let me know if accessing the values there can work out, and we can also change up any of the naming of files if you think that would help :)

angrezichatterbox commented 1 month ago

Ok, @angrezichatterbox, Scribe-i18n is now in the repo at main/app/src/main/res/i18n. Let me know if accessing the values there can work out, and we can also change up any of the naming of files if you think that would help :)

I will check accessing the files of i18n.

andrewtavis commented 1 month ago

Thanks so much, @angrezichatterbox! :)

angrezichatterbox commented 1 month ago

So this is how I have done it for now. When the gradle build starts there would be two tasks that have to occur before the gradle build it would the deletion of the README and LICENSE from the res since they are not in XML format and the folders string.xml would be transferred from i18n to their respective values-locale folder. The issue would be that the build takes a little longer than usual but the app complies. What do u think of doing it like this?. Also, there seem to be formatting errors in the XML which I would have to fix.

Some variables currently don't have a value in the strings.xml being referenced should I have a constant value in the XML layout or should I add those values to the string.xml? There seem to be a lot of them considering dialogue boxes and all.

andrewtavis commented 1 month ago

Hey @angrezichatterbox 👋 @henrikth93 and I were looking at this just right now. He was getting an error where the README was not valid within the res folder, so I reset the subtree add just now and we moved Scribe-i18n into the app/src/main/assets/i18n directory. As I understand it, res has specific filetype restrictions, but the assets directory can serve a similar purpose and would allow us to not need to delete the files on build? Big thing is that the way things work, we cannot just delete those files as that would screw up the git log for the subtree.

Let me know how this sounds, and thanks for the efforts so far! 😊

angrezichatterbox commented 1 month ago

Hey @angrezichatterbox 👋 @henrikth93 and I were looking at this just right now. He was getting an error where the README was not valid within the res folder, so I reset the subtree add just now and we moved Scribe-i18n into the app/src/main/assets/i18n directory. As I understand it, res has specific filetype restrictions, but the assets directory can serve a similar purpose and would allow us to not need to delete the files on build? Big thing is that the way things work, we cannot just delete those files as that would screw up the git log for the subtree.

Let me know how this sounds, and thanks for the efforts so far! 😊

Yes It would be much better. I was creating a temporary folder for regenerating it after the build but this would be much better. Do u have any suggestions for generating the values of different locales during the build or should I look into other possible ways to do this?

andrewtavis commented 1 month ago

Do u have any suggestions for generating the values of different locales during the build or should I look into other possible ways to do this?

What do you mean by this, @angrezichatterbox? Shouldn't we just have all the locales there and only offer those four that we currently have? I think the way that it works for iOS is that English-US is the default for all other locales. Would that solve the issue?

angrezichatterbox commented 1 month ago

I considered using the Android build-in support for locales by shifting the assets folder languages to the values folder for various locales during build only. We could very well use the assets folder itself for the locales but it wouldn't be able to completely use Android build in features. I am comfortable doing whichever sounds good to you. :)

andrewtavis commented 1 month ago

Would moving Scribe-i18n to the values directory make more sense? I'm happy to do that now if it would :) Aside from that, happy to have it setup for the build as you see fit!

angrezichatterbox commented 1 month ago

Can the contents of the values folder be made to the res/ That would be helpful. In that case, I would have to rename the contents to values-. or else I would have to set up for pre-gradle build.

angrezichatterbox commented 4 weeks ago

I have made a PR for this issue. I have broken it into 3 commits consisting of the addition of the script and pre-built values. And then further adding those values to activities and method.xml

andrewtavis commented 4 weeks ago

Closed by #57 🚀 Will write you on element about next steps, @angrezichatterbox! Really amazing progress so far, and hopefully the sailing just got a lot smother now that we have colors and strings fully defined 😊