Skip to main content

Real-Time Preview

All translations done in the Crowdin Editor can be displayed in your version of the application in real-time. See the translations that have already been done and the ones you're typing.

Setup​

Add the following code to the Application class:

override fun onCreate() {
super.onCreate()

Crowdin.init(applicationContext,
CrowdinConfig.Builder()
.withDistributionHash(your_distribution_hash)
.withRealTimeUpdates()
.withSourceLanguage(source_language)
.withAuthConfig(AuthConfig(
client_id,
client_secret,
redirect_uri,
request_auth_dialog
))
.withOrganizationName(organization_name) // required for Crowdin Enterprise
.withNetworkType(network_type) // optional
.withUpdateInterval(interval_in_seconds) // optional
.build())
}

Authorization​

Crowdin authorization is required for the Real-Time Preview feature. Create the connection in your Activity or Fragment class (e.g., in the MainActivity onCreate method):

override fun onCreate(savedInstanceState: Bundle?) {
Crowdin.authorize(this)
}

You can disconnect via:

override fun onDestroy() {
super.onDestroy()
Crowdin.disconnectRealTimeUpdates()
}
Tips

Config options​

Config optionDescriptionExample
withDistributionHashDistribution HashwithDistributionHash("7a0c1...7uo3b")
withRealTimeUpdatesEnable Real-Time Preview featurewithRealTimeUpdates()
withSourceLanguageSource language code in your Crowdin projectwithSourceLanguage("en")
withAuthConfigCrowdin authorization configwithAuthConfig(AuthConfig("client_id", "client_secret", "redirect_uri"))
client_id, client_secretCrowdin OAuth Client ID and Client Secret"gpY2yC...cx3TYB", "Xz95tfedd0A...TabEDx9T"
redirect_uriOAuth redirect URI (optional, defaults to "crowdintest://")"your-custom://redirect" or "crowdintest://"
request_auth_dialogRequest authorization dialogtrue by default or false
withOrganizationNameAn Organization domain name
(for Crowdin Enterprise users only)
"mycompany" for Crowdin Enterprise or null for crowdin.com

Redirect URI Configuration​

You can configure the OAuth redirect URI for authorization in two ways:

  • Via AuthConfig (Recommended): Specify the redirect URI directly in your AuthConfig. This method provides more flexibility and doesn't require manifest configuration.
  • Via App Scheme in Manifest: Configure the redirect URI using app scheme in your AndroidManifest.xml. When using this method, the redirect URL in your Crowdin OAuth app should be crowdintest://.

The OAuth App redirect URL should match your configured redirect URI:

  • When using AuthConfig method: Set the redirect URL to match the redirect_uri parameter value (e.g., "your-custom://redirect")
  • When using App scheme method: Set the redirect URL to match your app scheme (e.g., for scheme <data android:scheme="crowdintest" /> use crowdintest://)