-
-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generated file contains strings from default resource value #10
Comments
Hi @bmarty, many thanks for your feedback! I see. There's a way we can sort it out that hopefully will suit you, if not, please let me know. Though basically you can avoid getting such string into other languages' generated files if you set its <string name="template_string_2" translatable="false">This is a second example for ${app_name}</string> Please let me know if that doesn't work for you. Regards, |
Thanks for the fast answer. |
I see, got it. I remember leaving it like that to avoid double checking whether the user provided a translation because doing so could cause some performance penalties (and just leaving the string on the specific language wasn't causing any compilation issues, but I didn't think of lint issues) and also because I was thinking that, if someone didn't need a string translated, then they could just add the In any case, I'm planning working on a refactoring soon, mostly to have a better, well defined separation of concerns across the different processes of this plugin, and also to stop using deprecated Gradle plugin tools (based on this other issue: #5) so I can add this extra validation as part of that work as well, hopefully the new design will make it easier to validate this case without the performance penalties. In the meantime though, if all the issues you're facing right now are only lint-related ones, I'd suggest you to either adding the I'll update this ticket once the improvements are available, however, being honest those could take up to 2 months from now since they have a lower level priority than the improvements I'm currently working on for https://github.com/LikeTheSalad/android-buddy - however, I hope my suggestions above can work for you in the meantime 👍 Regards, |
Wonderful, thanks! For now I have disabled the lint check on those files (like that: https://github.com/vector-im/element-android/blob/develop/vector/lint.xml#L75). I work on a project with many translations, so I can definitely not add Anyway, there is no urgency to fix this issue! I was also wondering if the plugin could also strip out the string starting with Thanks! |
Cool! glad you found a temporary solution 👍 That's also a great thing to consider when making the refactoring, I didn't know whether people would like to keep or not those template strings, so it is nice to have some input on that, thanks! I'll check what can be done about it. Regards, |
Hi @bmarty, this issue should be fixed now in version 1.3.0. Please feel free to reopen this ticket if you find that's not the case. |
Hello @LikeTheSalad , The first error is:
but the string (the template actually) is well defined in the default resource: https://github.com/vector-im/element-android/blob/d07dd154b8a4b961f3a14c0a1e30a921798eee3a/vector/src/main/res/values/strings.xml#L1101 Do you have an idea why we have this problem? |
Oh, I think I know what's going on 🤦♂️ - I did add the validation to check for a template's location before storing the resolved string in a language folder, but now that I think about it better, even though this plugin knows about their connection (template and resolved string), still Android's lint rules don't... So to them they're still different resources, and it's not able to find the resolved resource in the raw ones. So I think this will actually get solved for good as part of #15 where I'm going to get rid of the "template_" prefix for template resources, as I explained there in a comment. The idea is to have both template and resolved strings named the same, that way not only we'd avoid adding unwanted resources into the final binary, but also it will no longer be needed to compile the project for the resolved strings to become available into the code. Not sure how long this change will take, but at least the refactoring needed to make this plugin more flexible for these kind of changes is finished now as part of the code added into 1.3.0, so it shouldn't be as painful as what was needed to be done for 1.3.0, but definitely the way to use this plugin will change, as the "template_" prefix will not longer be needed, so that'll become version 2.0.0. |
Thanks! I'll wait for v2.0.0 to consider upgrading our dependency then. |
Hi @bmarty - The new version 2.0.0 is now available, it is no longer needed to define your templates by adding the "template_" to your string names anymore, which means that Lint shouldn't treat them as separate strings, thus avoiding the "translation" issue. Although, please bear in mind that a lot of things have changed in this new version 2.0.0, there's a rebranding along with new dependencies parameters and plugin ID, so in order to add the new version into your project, I recommend you to check again the README's instructions: https://github.com/LikeTheSalad/android-stem#21--changes-to-your-roots-buildgradle-file |
Thanks @LikeTheSalad ! Migrating to 2.0.0 is fine so far! |
This gradle plug-in works pretty well, but I noticed a problem when there are some missing template translations
For instance:
With file
values/strings.xml
And French file
values-fr/strings.xml
with missing translation fortemplate_string_2
Generated file
values-fr/resolved.xml
will containI do not expect string_2 to be include in the generated file for French, since it will be already included in the generated file
values/resolved.xml
.This can lead to issue reported from lint (Typos, etc.).
The text was updated successfully, but these errors were encountered: