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,
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 Real-Time Preview feature. Create connection using Activity/Fragment method inMainActivity class:

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

You can disconnect via:

override fun onDestroy() {
super.onDestroy()
Crowdin.disconnectRealTimeUpdates()
}
Tips
  • To use the Real-Time Preview feature you still need to wrap context for your activities.
  • The OAuth App redirect URL should match your App scheme.
    E.g., for scheme <data android:scheme="crowdintest" /> redirect URL in Crowdin should be crowdintest://.
  • To easily control the Real-Time Preview feature you could also use the SDK Controls UI widget.

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"))
client_id, client_secretCrowdin OAuth Client ID and Client Secret"gpY2yC...cx3TYB", "Xz95tfedd0A...TabEDx9T"
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