Text Translation Libraries in Android

Libraries you can use to implement translation within the app.

(a). Tadur

Tradur is a text translation Android library that allows your app's users to easily translate any text content in the app to their device's language. It is built on top of the MLKit API, which supports translating text from and to more than 50 languages. This library can be very useful for social media apps or in apps where users post content in different languages. Tradur was inspired by Instagram's "See translation" feature.

Here is the demo of the sample app:

Installation

To download Tradur, follow these steps:

  1. Add the following code to your root build.gradle at the end of repositories:
allprojects {
    repositories {
    ..
    maven { url 'https://jitpack.io' }
    }
}
  1. Add the dependency:
implementation 'com.github.husaynhakeem:android-tradur:2.0'

Usage

Using Tradur is as easy as following two steps. The first step is to create a textView and assign it an id. You can do this by adding the following code to your app:

<TextView
    android:id="@+id/textview"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="Text you want the user to be able to translate" />

The second step is to define a TradurTextView element in the same layout and link it to the textView you just created using its id. You can do this by adding the following code to your app:

<io.husaynhakeem.tradur.TradurTextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:translate_field="@+id/textview"
... />

Customizations

Tradur offers three customization options: the pre-translation message, the loading message, and the post-translation message. The pre-translation message is the text displayed in the TradurTextView element before the user chooses to translate text content. By default, it's set to "See translation". The loading message is the text displayed in the TradurTextView element while the translation is ongoing. By default, it's set to "Loading…". The post-translation message is the text displayed in the TradurTextView element after the translation is done. By default, it's set to "See original".

It is great tool for Android developers who want to make their apps more accessible to users who speak different languages. With its simple setup process and customizable options, it's easy to integrate into any app. Check out the demo and download it to get started today.

URL to this page where you can learn more: https://github.com/husaynhakeem/android-tradur.