LanguagesHelper

object LanguagesHelper

Use the static methods in this class to do all language-related operations.

Summary

Functions
Void fun availableLanguages(
  applicationContext: Context,
  callback: (Result<List<RemoteLanguage?>>) -> Unit
)
Downloads the list of available languages.
Void fun downloadLanguageFile(
  applicationContext: Context,
  language: String,
  destination: File,
  detailedProgress: ((downloadedBytes: Long, totalBytes: Long) -> Unit)? = null,
  callback: (result: Result) -> Unit?
)
Downloads the file containing the specified language.
LocalLanguage? fun getMetadataFromLanguage(path: String)
Creates the language metadata object from the language file at the specified path.

Functions

availableLanguages

fun availableLanguages(
    applicationContext: Context,
    callback: (Result<List<RemoteLanguage?>>) -> Unit
)

Downloads the list of available languages.

Parameters
applicationContext: Context The application’s context
callback: (Result<List<RemoteLanguage?>>) -> Unit A callback to monitor completion or error

downloadLanguageFile

fun downloadLanguageFile(
    applicationContext: Context,
    language: String,
    destination: File,
    detailedProgress: ((downloadedBytes: Long, totalBytes: Long) -> Unit)? = null,
    callback: (result: Result<Unit>) -> Unit?
)

Downloads the file containing the specified language.

Parameters
applicationContext: Context The application’s context
language: String The locale of the language file you want to download
destination: File A file to define the path where the file will be downloaded
detailedProgress: ((downloadedBytes: Long, totalBytes: Long) -> Unit)? = null a listener to monitor progress
callback: (result: Result<Unit>) -> Unit? A callback to monitor completion or error

getMetadataFromLanguage

fun getMetadataFromLanguage(path: String): LocalLanguage?

Creates the language metadata object from the language file at the specified path.

Parameters
path: String The Path to the language file.
Returns
LocalLanguage? An object with all the metadata for the specified language

If something needs to be added or if you find an error in our documentation, please let us know either on our GitHub or Discord.

Last updated on July 29, 2022