Skip to content
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

ExtractionState config #46

Open
VadimPavlov opened this issue Mar 27, 2024 · 3 comments
Open

ExtractionState config #46

VadimPavlov opened this issue Mar 27, 2024 · 3 comments

Comments

@VadimPavlov
Copy link

VadimPavlov commented Mar 27, 2024

Right now the code checks for extractionState == .manual and produces result only in this case.
This is probably correct thing to do by default. However in our situation, we have strings stored in online tool (so it can be pulled for both iOS/Android projects), it's a source of truth for us. And after downloading xscstrings catalog, extractionState is missing (and will be set to stale after build), so nothing will be generated.

It'll be nice to have some way of extractionState check configuration from outside, thanks!

@liamnichols
Copy link
Owner

Thanks for reporting this! This is an interesting issue 🤔 It seems that Xcode will consider a string with a missing extractionState as automatically managed:

Screenshot 2024-03-28 at 13 04 45

The reason that we skip/warn about Automatically managed strings is that there is potential for Xcode to see the generated definition try to update the source in the Strings Catalogs (essentially overwriting what you have defined) which is something that we want to avoid.

Before going down the route of overriding this, could you confirm if you have spoken with your translation platform about this? I would expect that the value should be either preserved from upload, or set to manual if your generating a Strings Catalog from phrases that are defined in the platform directly.

As a temporary workaround, you could use jq to post-process the file after downloading:

jq --indent 2 '.strings |= map_values(if has("extractionState") then . else {"extractionState": "manual"} + . end)' Localizable.xcstrings > Localizable.xcstrings.tmp && mv Localizable.xcstrings.tmp Localizable.xcstrings

@VadimPavlov
Copy link
Author

Thanks for workaround.
I have already contacted team of online tool, to set this field to manual or provide option to configure it.

However, there might be others edge cases with this field.
I believe this should be an easy fix on tool side. For example some static variable (array?) with StringExtractionState value to ignore/warning probably?

@liamnichols
Copy link
Owner

It's relatively easy to add configuration options to the CLI, but there isn't really a good way to pass flags through when using the Package Plugin (I don't encourage the usage of the CLI directly atm).

I'm interested to see which other scenarios where the extractionState is set to something other than manual or automatic to understand if the customisation would be the appropriate way to handle it or not

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants