Instruction 1

Heads up... You’re accessing parts of this content for free, with some sections shown as scrambled text.

Heads up... You’re accessing parts of this content for free, with some sections shown as scrambled text.

Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.

Unlock now

You may want to localize the app’s UI dynamically based on the user’s language preferences or have more control if the system can’t detect some translation strings due to improper data. With these cases in mind, here’s when you should consider using the TranslationSession API over the built-in Translation UI.

TranslationSession provides many different benefits. It provides consistent experience. This is useful when you need to maintain consistency across multiple translations, such as in a document or a series of related UI elements. TranslationSession is also quite performant. When you require efficient processing of large volumes of text, especially in scenarios where performance and speed are critical. It also provides a lot of additional advantages such as:

  • Effectively Handling Multiple Translations: TranslationSession is designed to handle a batch of texts and maintain consistency in translation quality and style. This ensures that related texts are translated coherently, crucial for maintaining context and meaning across multiple strings​.

  • Performance Efficiency: Since the translations are performed on-device, batch processing within a TranslationSession can be more efficient than sending individual requests. This reduces the impact on system resources and minimizes latency. The API can optimize processing by reusing translation models and resources, shortening the time taken for multiple translations​.

  • Managing High-Volume Text: For apps that need to handle high volumes of text translation, such as news apps or content management systems, the ability to batch process translations makes it scalable and capable of handling large datasets efficiently for complex multilingual workflows.

  • Better User Experience: TranslationSession operates asynchronously, allowing your app to continue performing other tasks while translations are in progress. For end-users, translating multiple strings in a single session can result in faster response times and a smoother experience. It also avoids freezing or blocking the UI because the app doesn’t need to wait for multiple translation requests to complete sequentially​.

  • Customizability: The TranslationSession brings a lot of customizability to make your app suitable for people from any location. It’s flexible enough to let you specify the source and target languages for your translations. It can provide additional context to improve translation accuracy. It helps you implement custom error handling to gracefully deal with errors and fallback scenarios more easily. If an error occurs during the translation of one string in the batch, it can be handled in a unified way, making the process more predictable and easier to debug​

  • Better System Integration: The Translate API will constantly be updated based on Apple’s ongoing improvements to translation accuracy and performance to provide users with a familiar and integrated experience across all their Apple devices. The API also adheres to Apple’s privacy standards, ensuring user data is handled securely and complies with relevant regulations.

As you can see, there are a lot of reasons to incorporate TranslationSession versus using the built-in Translation UI.

See forum comments
Download course materials from Github
Previous: Introduction Next: Instruction 2