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

No localized strings detected when .strings files are in different module #299

Open
ffittschen opened this issue Nov 20, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@ffittschen
Copy link

Describe the bug
In a modular app, the Localizable.strings files are not necessarily in the main bundle, because other modules need to access the translations as well. In our case, we have a Localization target, which contains all .strings and .stringsdict resources. When using the Crowdin SDK with our app, some features do not work, as the LocalLocalizationExtractor assumes the files are part of the Bundle.main.

To Reproduce
Steps to reproduce the behavior:

  1. Move all localization resource files into a separate target
  2. Integrate the Crowdin SDK
  3. Use the features such as capturing screenshots via the SDK
  4. See error in the debug console

Expected behavior
I would expect to be able to pass a Bundle when setting up the Crowdin SDK so that the SDK knows where to look for the localizable resource files when trying to extract the strings.

@ffittschen ffittschen added the bug Something isn't working label Nov 20, 2024
@serhii-londar
Copy link
Collaborator

@ffittschen Please share errors you see in logs.
Do strings from crowding are displayed on screen?
Do you use xcstrings for your localization files?

@ffittschen
Copy link
Author

Hi @serhii-londar, when I tap the Capture screenshot button in the Crowdin debug menu, I get the following error:

Error while capturing screenshot - The operation couldn’t be completed. (There are no localized strings detected on current screen. error 99999.)

I knew that my language is the source language, so I put some breakpoints in the CrowdinSDK and traced it back to the stringsFiles and stringsdictFiles in the LocalLocalizationExtractor being empty arrays due to the assumption of them being part of the main bundle.

@serhii-londar
Copy link
Collaborator

@ffittschen Crowding SDK does not detect localized strings based on any local localization. The detection is based on strings in Crowdin project. LocalLocalizationExtractor - just utility class which have no relation to Screenshots.
Potential issues might be that you're using xcstrings files in crowdin. Currently there is no mapping support for this files so screenshots and realtime updates are not working.
Please confirm that you are using xcstring. Otherwise it's different kind of issue and please contact support with project details(project hash) so we can investigate the issue.

@ffittschen
Copy link
Author

Hi @serhii-londar, thanks for the details. We're not using xcstrings, we are using .strings and .stringsdict and the distribution in our Crowdin project is set to use original file format.

As far as I can see, the ScreenshotInformationCollector tries to call getControlsInformation, which accesses the label.localizationKey, which is set to Localization.current.keyForString(text) in the Label+Swizzle.swift. Within the keyForString implementation, the provider is asked first, but if the provider does not return a key, the extractor is asked. This is how I found out that the extractor cannot provide a key, as it tries to extract from the hardcoded main bundle, which does not contain our localized strings.

I'll contact support to clarify why the provider doesn't contain anything in our case and it needs to fall back to the extractor. But the reported issue with the hardcoded .main bundle is still a problem (as it effectively undermines the fallback), so I'll keep the issue open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants