An android library to integrate translation service for your app easily. Uses From-to.uz free API service for translation. Supports translations to Karakalpak and 140+ other languages
- Include jitpack in your root
settings.gradle
file.
pluginManagement {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
...
maven { url 'https://jitpack.io' }
}
}
- And add it's dependency to your app level
build.gradle
file:
dependencies {
implementation 'com.github.theberdakh:From2:1.0.1'
}
- You can call to translate from any screen or class:
val text = "What a wonderful morning!"
lifecycleScope.launch {
translate(TranslateLanguage.ENGLISH_LATIN,
TranslateLanguage.KARAKALPAK,
text = text,
onSuccess = { text ->
//Successfully translated
binding.editTextBottomInput.setText(text)
},
onMessage = { message ->
//Message returned from server
binding.editTextBottomInput.setText(message)
},
onError = { error ->
//Error happened
error.printStackTrace()
})
}
- make sure you've added permissions for android.permission.INTERNET to your app manifest, before translating text.
Note: You can run the sample project in the repo, to see how it works!
📌 Please, feel free to give me a star 🌟, I also love sparkles ✨
Developed with 💖 by
Berdakh Tlepov