Skip to content

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

License

Notifications You must be signed in to change notification settings

theberdakh/From2

Repository files navigation

From2 Android Library

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

Screenshot from sample app

1. Adding From2 to your project

  • 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'
}

Sync your project, and 😱 boom 🔥 you have added From2 successfully:

2. Usage

  • 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

Authors

Download

About

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

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages