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.
Improve CDSHandler push logic
The
pushTranslations()
method now returns a secondary array ofError
objects in the completion handler that represents the generated warnings
during the processing of the source strings that are non-fatal but can
be of interest to the developer.
This change introduces a new enum (
TXCDSWarning
) that hosts thosewarnings, like duplicate source string and empty key detection.
The
pushTranslations()
logic has been improved by implementing thefollowing changes:
serializeTranslations()
is now a private static method as it doesnot need to look into the state of the
CDSHandler
instance.Result<Data>
objectas the first member, revealing whether the serialization
was successful, thus offering the
Data
object, or a failure, thusoffering a
Error
object for further propagation and an array ofTXCDSWarning
objects for any generated warnings during the processingof the source strings.
pushTranslations()
implementation has been split so that it'seasier to be read. The new method that performs the asynchronous network
operation is now separate (
pushData()
) and propagates the generatedwarnings to the
pollJobStatus()
method.Error
objects in the completion handler. The logging is now a responsibility
of the consumer.
Introduce t() method
A new public static method has been introduced in the
TXNative
class,allowing developers to programmatically trigger the translation
mechanism of Transifex SDK in cases where this is not supported.
For example, in SwiftUI, where the swizzling mechanism of Transifex SDK
does currently work, developers can replace views like this:
with this:
The method uses the default locale that Transifex SDK has been
configured with.
Note: If you want to change the current locale used by the
SwiftUI preview to test different locales, click on the 'Product' menu
item and then visit 'Scheme' > 'Edit Scheme...' > 'Run' > 'Options' >
'App Language' and pick the language you want to test.