Screenshots
Enable this option if you want all screenshots taken in the application to be automatically sent to your Crowdin project with tagged strings. This provides additional context for translators.
You can take screenshots and automatically upload them tagged to Crowdin in the following ways:
- using the system buttons for taking a screenshot.
- create your own handler (for example, clicking on some button in your application).
- using the SDK Controls UI widget.
Setup
To enable the Screenshots feature, add the following code to the Application class:
- Kotlin
- Java
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)
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Crowdin.init(this,
new CrowdinConfig.Builder()
.withDistributionHash(your_distribution_hash)
.withScreenshotEnabled()
.withSourceLanguage(source_language)
.withAuthConfig(new 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
- Kotlin
- Java
override fun onCreate(savedInstanceState: Bundle?) {
Crowdin.authorize(this)
}
@Override
public void onCreate(@Nullable Bundle savedInstanceState, @Nullable PersistableBundle persistentState) {
super.onCreate(savedInstanceState, persistentState);
Crowdin.authorize(this);
}
Setting up own handler
If you want to set up your own handler for capturing screenshots, you can do it programmatically with a callback:
- Kotlin
- Java
Crowdin.sendScreenshot(activity!!, object : ScreenshotCallback {
override fun onSuccess() {
Log.d(TAG, "Screenshot uploaded")
}
override fun onFailure(throwable: Throwable) {
Log.d(TAG, throwable.localizedMessage)
}
})
View.OnClickListener oclBtnOk = new View.OnClickListener() {
@Override
public void onClick(View v) {
Crowdin.sendScreenshot(YourActivity.this, new ScreenshotCallback() {
@Override
public void onSuccess() {
Log.d("", "Screenshot uploaded");
}
@Override
public void onFailure(Throwable throwable) {
Log.d("", String.valueOf(throwable));
}
});
}
};
Tips
- To use the Screenshots 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 becrowdintest://
. - To easily control the Screenshots feature you could also use the SDK Controls UI widget.
Config options
Config option | Description | Example |
---|---|---|
withDistributionHash | Distribution Hash | withDistributionHash("7a0c1...7uo3b") |
withScreenshotEnabled | Enable Screenshots feature | withScreenshotEnabled() |
withSourceLanguage | Source language code in your Crowdin project | withSourceLanguage("en") |
withAuthConfig | Crowdin authorization config | withAuthConfig(AuthConfig("client_id", "client_secret")) |
client_id , client_secret | Crowdin OAuth Client ID and Client Secret | "gpY2yC...cx3TYB" , "Xz95tfedd0A...TabEDx9T" |
request_auth_dialog | Request authorization dialog | true by default or false |
withOrganizationName | An Organization domain name (for Crowdin Enterprise users only) | "mycompany" for Crowdin Enterprise or null for crowdin.com |
caution
Using the Crowdin.registerScreenShotContentObserver(this)
(system button handler) to send screenshots to Crowdin requires storage permission for your application.