-
Notifications
You must be signed in to change notification settings - Fork 5
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
Disagreements in token count are not handled correctly #29
Comments
It's also worth considering how this might happen.
Both of these are at odds, unless we use something like XML attributes to inform behavior. We did this in Android's view binding for very exceptional cases. The other case is that you remove a token from |
My preference here is to fail fast and have an XML attribute in the default configuration to define the full set of supported names. So both examples above fail the build unless you add Not sure how translation services will handle this... I assume since the The presence of the attribute on any non-default configurations is an error, although some tool might copy this over, so maybe if the value matches we allow it. But disagreements in the XML attribute value always fail. |
Great question. I can imagine projects with different translation pipelines wanting to treat this case differently. First, from the Cash perspective.
We're planning to run a cron job that updates translations periodically (say every 12 hours). Developers never make changes to other languages - those string files are generated by the tooling. So there will be several cases where strings are temporarily out of sync on master:
All of that is fine. We'll have some extra validation that we run on release builds to make sure that we have a full set of up-to-date translations, but we don't block developers from merging to master. So for us, I think that mismatched argument counts/types/names is not a huge deal (at least on master). We can treat the English strings as the source of truth, and there may be some period of time where other languages lag behind, but in most cases it's no worse than any other string change (you might see a placeholder, or an argument that you pass might not be used). I do think that there will be some edge cases where changing a type leads to a crash when using other languages on a master build, but:
So for Cash I'm fine with emitting a warning, but would prefer not to fail.
I think not, I would consider that a mistranslation. It might happen in the short term on a master build after updating a string, but I'm not aware of any long term situation where it would be valid. |
Other projects will have different translation pipelines though, and may want to be stricter. If they update strings synchronously across languages they might want to fail if the tokens don't match. Maybe we could offer a configuration option that enables/disables strict argument checking? Cash could enable it only for release builds but other projects could decide for themselves? |
👍 This should be allowed and should get a generated code binding.
👍 I don't think it's an unreasonable policy for this tool to say that you must delete all translations of a string if you delete the string. However, regardless of whether I think you should do this or not, we don't have to enforce it. But then I think these orphaned strings do not get a generated code binding.
There are two phases to this in your list of steps. The second phase is the same as the "Adding Strings" case above. The first phase is between these two steps:
There are at least three okay forms of this phase:
However, there are at least three Very Bad™ forms of this phase:
👍 This is basically an extreme form of "Adding Strings".
For Cash we can be lenient where possible. In general I would prefer the tool to be as strict as possible and provide opt-out configurations where it's possible to provide behavior that is not perfect.
If we have the tool be strict by default, it will also serve as validation that someone could rely on if they don't have a separate translation service and tooling. And if the leniency is configurable, it ensures we only allow our developer builds to be the ones which opt-out of any kind of strict validation. |
Yeah that's fair. We're going to have a separate plugin for managing translations and I think we could do something there to make this relatively painless.
Agreed
I'm comfortable with that. Later on we can decide internally if we'd rather:
|
res/values/strings.xml
:res/values-es/strings.xml
:They also could disagree on names:
res/values/strings.xml
:res/values-es/strings.xml
:Currently it seems like only tokens from the main configuration are parsed. Or maybe they're all parsed but it's first/last wins.
The text was updated successfully, but these errors were encountered: