Skip to main content

Screenshots

The Screenshots feature enhances the localization workflow by automatically capturing and uploading tagged screenshots from your application to your Crowdin project. This provides translators with valuable visual context, ensuring more accurate and contextually appropriate translations.

Overview

You can capture and upload tagged screenshots to Crowdin in three ways:

  1. System Screenshot Buttons: Utilize the default system buttons/gestures for taking screenshots
  2. Custom Handler: Implement your own screenshot trigger (e.g., an in-app button or gesture, or an automated workflow)
  3. SDK Controls Widget: Use the built-in SDK Controls UI widget for easy management

Setup

To enable the Screenshots feature in your application, add the following configuration to your Application class:

override fun onCreate() {
super.onCreate()

Crowdin.init(applicationContext,
CrowdinConfig.Builder()
.withDistributionHash(your_distribution_hash)
.withScreenshotEnabled()
.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())
}

// Using system buttons to take screenshots and automatically upload them to Crowdin.
Crowdin.registerScreenShotContentObserver(this)

Authorization

The Screenshots feature requires authorization to transmit screenshots to your Crowdin project. Choose from two authorization methods based on your needs:

  • OAuth-based Authorization: Uses client_id and client_secret for web-based authorization. This method implements a secure OAuth flow that opens a dialog for users to authorize the application. Best suited for development environments and when user interaction is acceptable.
  • API Token Authorization: Uses the ApiAuthConfig to pass the apiToken directly. This streamlined method is ideal for automated workflows, CI/CD pipelines, or scenarios where user interaction is not desired.

OAuth-based Authorization

Implements a secure web-based authorization flow using client_id and client_secret. This method:

  • Opens a dialog for user authorization
  • Provides a secure authentication process
  • Is ideal for development and testing environments
override fun onCreate(savedInstanceState: Bundle?) {
Crowdin.authorize(this)
}
info
  • When using OAuth, verify that your OAuth App redirect URL matches your App scheme. For example, if your scheme is <data android:scheme="crowdintest" />, the redirect URL in Crowdin should be crowdintest://.
  • To easily control the Screenshots feature you could also use the SDK Controls UI widget.

API Token Authorization

A streamlined approach using the ApiAuthConfig class that bypasses OAuth authentication. This method:

  • Allows direct API token integration
  • Requires no user interaction
  • Is perfect for CI/CD pipelines and automated workflows
.withApiAuthConfig(
ApiAuthConfig(
apiToken = "your_crowdin_api_token",
)
)

Custom Screenshot Handler

Implement your own screenshot capture logic by setting up a custom handler. This provides complete control over the screenshot capture process and allows integration with your application's specific requirements.

Crowdin.sendScreenshot(activity!!, screenshotName, object : ScreenshotCallback {
override fun onSuccess() {
Log.d(TAG, "Screenshot uploaded")
}

override fun onFailure(throwable: Throwable) {
Log.d(TAG, throwable.localizedMessage)
}
})

Config Options

Config optionDescriptionExample
withDistributionHashDistribution HashwithDistributionHash("7a0c1...7uo3b")
withScreenshotEnabledEnable Screenshots featurewithScreenshotEnabled()
withSourceLanguageSource language code in your Crowdin projectwithSourceLanguage("en")
withAuthConfigCrowdin authorization configwithAuthConfig(AuthConfig(client_id, client_secret, request_auth_dialog))
client_id, client_secretCrowdin OAuth Client ID and Client Secret"gpY2yC...cx3TYB", "Xz95tfedd0A...TabEDx9T"
request_auth_dialogRequest authorization dialogtrue (default) or false
withApiAuthConfigCrowdin authorization API configwithApiAuthConfig(ApiAuthConfig(api_token))
api_tokenCrowdin authorization token"gpY2yC...cx3TYB"
withOrganizationNameAn Organization domain name
(for Crowdin Enterprise users only)
"mycompany" for Crowdin Enterprise or null for crowdin.com
tip

See the OAuth and API sections in your Crowdin account settings to obtain the necessary credentials.

caution
  • Ensure you've properly wrapped context for all activities where screenshots will be captured.
  • Using the Crowdin.registerScreenShotContentObserver(this) (system button handler) to send screenshots to Crowdin requires storage permission for your application.