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

Copies/translations not fetched inside the completion block of CrowdinSDK.startWithConfig on a fresh install #187

Open
stevi-clue opened this issue Apr 26, 2022 · 6 comments
Labels
bug Something isn't working documentation Improvements or additions to documentation help wanted Extra attention is needed

Comments

@stevi-clue
Copy link

stevi-clue commented Apr 26, 2022

Hi there!

I successfully integrated the CrowdinSDK in my app using Swift Package Manager and I am using OTA content delivery. On the first app launch with internet enabled, when I enter the completion block of CrowdinSDK.startWithConfig, and fetch the copy for a specific key using NSLocalizedString(key, comment: ""), I am only getting the key and not the copy. If I kill and relaunch the app, the copy for the same key is fetched successfully.

Do you know what might be causing this and do you have any suggestion on its mitigation?

Many thanks!

@stevi-clue stevi-clue added the bug Something isn't working label Apr 26, 2022
@DimaYashchyshyn-zz
Copy link

Hi @stevi-clue
Checking this :)

@stevi-clue
Copy link
Author

stevi-clue commented Apr 26, 2022

Thanks for the fast reply Dima! :)

I was playing a bit around with breakpoints in the SDK and my hunch is that it might be due to Localization.refreshLocalization() -> Localization.fetchRemoteLocalization() being first called when the localization is set in the LocalizationProvider(). The LocalizationProvider is initialized in the setRemoteStorage which does not call a completion block when it is done.

Maybe passing the completion handler from CrowdinSDK.startWithConfig all the way to Localization.fetchRemoteLocalization() might solve this?

@andrii-bodnar
Copy link
Member

@serhii-londar could you please assist with this?

@serhii-londar
Copy link
Collaborator

serhii-londar commented Apr 27, 2022

Hi @stevi-clue, you need to add a download handler:

CrowdinSDK.addDownloadHandler {
            NSLocalizedString(key, comment: "")
}

@serhii-londar
Copy link
Collaborator

serhii-londar commented Apr 28, 2022

@stevi-clue Does it help?

@chrispomeroyhale
Copy link

My team had a similar question as well.

In my opinion, the completion parameter to startWithRemoteStorage is not well documented as to what receiving a completion callback means to us client apps. In our observation startWithRemoteStorage ultimately calls three different network endpoints. What if one of them fails? CrowdinSDK.addDownloadHandler has the same documentation issue -- is that called for each individual translation file or for when all of them are done?

I think the more communicative approach would have been to have a single callback that tells us what state the SDK is in.

From my comments here, here, and here, the emerging theme in my opinion is that edge cases surrounding the initialization of the SDK are not well defined and automated tests have room to grow.

@andrii-bodnar andrii-bodnar added the help wanted Extra attention is needed label May 6, 2022
@andrii-bodnar andrii-bodnar added the hacktoberfest This issue welcomes contributions for Hacktoberfest label Sep 27, 2022
@andrii-bodnar andrii-bodnar removed the hacktoberfest This issue welcomes contributions for Hacktoberfest label Jun 15, 2023
@andrii-bodnar andrii-bodnar added documentation Improvements or additions to documentation bug Something isn't working and removed bug Something isn't working labels Oct 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

5 participants