feat: add completion handler for localization changes and update documentation#377
Open
serhii-londar wants to merge 1 commit intomasterfrom
Open
feat: add completion handler for localization changes and update documentation#377serhii-londar wants to merge 1 commit intomasterfrom
serhii-londar wants to merge 1 commit intomasterfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds a completion handler-based API for the setCurrentLocalization method, allowing developers to be notified when localization changes complete. This enables better UI synchronization when switching languages.
Changes:
- Added public
setCurrentLocalization(_:completion:)method toCrowdinSDKclass - Refactored
LocalizationProviderProtocolto makelocalizationproperty read-only and addedsetLocalization(_:completion:)method - Updated all protocol implementations (production and test mocks) to conform to the new protocol signature
- Added comprehensive test coverage for the new completion-based API
- Updated documentation with usage examples
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
Sources/CrowdinSDK/CrowdinSDK/CrowdinSDK.swift |
Added public setCurrentLocalization(_:completion:) method with documentation |
Sources/CrowdinSDK/CrowdinSDK/Localization/Localization.swift |
Refactored internal localization setter to use new completion-based method |
Sources/CrowdinSDK/CrowdinSDK/Localization/Provider/LocalizationProvider.swift |
Changed protocol to make localization read-only, added setLocalization(_:completion:) method to protocol and implementation |
Tests/UnitTests/MockLocalizationProvider.swift |
Updated mock to implement new protocol method, fixed trailing whitespace |
Tests/UnitTests/InitializationCompletionHandlerTests.swift |
Added comprehensive tests for completion handler functionality |
Sources/Tests/Core/BundleSwizzleReentrancyTests.swift |
Updated test mocks to implement new protocol method |
website/docs/setup.mdx |
Added documentation and code example for the completion-based API |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #377 +/- ##
==========================================
+ Coverage 55.83% 56.22% +0.40%
==========================================
Files 136 136
Lines 6320 6377 +57
==========================================
+ Hits 3528 3585 +57
Misses 2792 2792 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note
Medium Risk
Changes the localization switching contract and refresh triggering behavior across the provider protocol, which could affect timing/side effects of language updates in apps and custom providers.
Overview
Adds a new completion-based API
CrowdinSDK.setCurrentLocalization(_:completion:)so callers can be notified when a language switch and localization refresh finishes.Refactors localization switching to flow through
Localization.setCurrentLocalization(..., completion:)and a newLocalizationProviderProtocol.setLocalization(_:completion:), replacing the previouslocalizationsetter side-effect that auto-refreshed ondidSet. Updates unit tests/mocks for the new protocol method and adds coverage that completion is called even when the SDK/provider isn’t initialized, and documents the new API inwebsite/docs/setup.mdx.Written by Cursor Bugbot for commit 8d78687. This will update automatically on new commits. Configure here.
Closes #370