Crowdin Android SDK delivers all new translations from Crowdin project to the application immediately. So there is no need to update this application via Google Play Store to get the new version with the localization.
The SDK provides:
Over-The-Air Content Delivery – the localized content can be sent to the application from the project whenever needed.
Real-Time Preview – all the translations that are done in the Editor can be shown in your version of the application in real-time. View the translations already made and the ones you're currently typing in.
Screenshots – all the screenshots made in the application may be automatically sent to your Crowdin project with tagged source strings.
For Android project which already have transitive dependency of com.google.code.gson, after integration of Crowdin SDK, it will show you the following error during build time:
Duplicate class com.google.gson.DefaultDateTypeAdapter found in modules xxx.jar (xxx.jar) and jetified-gson-2.8.5.jar (com.google.code.gson:gson:2.8.5)
To resolve, either exclude gson from Crowdin or from your library is OK, but be sure to keep the newer one for backward-compatibility.
Upload your xml localization files to Crowdin. If you have ready translations, you can also upload them.
Set up Distribution in Crowdin.
Set up SDK and enable Over-The-Air Content Delivery feature in your project.
Distribution is a CDN vault that mirrors the translated content of your project and is required for integration with Android app.
To manage distributions open the needed project and go to Over-The-Air Content Delivery. You can create as many distributions as you need and choose different files for each. You’ll need to click the Release button next to the necessary distribution every time you want to send new translations to the app.
Notes:
By default, the translation downloading happens asynchronously after launching the app. The downloaded translations will be used after the next launch of the app or Activity re-render. Otherwise, the previously cached translations will be used (or local translations if a cache does not exist). To enable the synchronous mode please see the Notes#9
The CDN feature does not update the localization files. if you want to add new translations to the localization files you need to do it yourself.
Once SDK receives the translations, it's stored on the device as application files for further sessions to minimize requests the next time the app starts. Storage time can be configured using withUpdateInterval option.
CDN caches all the translation in release for up to 15 minutes and even when new translations are released in Crowdin, CDN may return it with a delay.
To integrate SDK with your application you need to follow step by step instructions:
Inject Crowdin translations by adding override method in BaseActivity class to inject Crowdin translations into the Context. If you already migrated to AppCompat 1.2.0+ version. Please use this method:
Note! If you don’t have BaseActivity class add the following code to all of your activities.
Enable Over-The-Air Content Delivery in your project so that application can pull translations from CDN vault. Add the following code to App/Application class:
Translations update interval in seconds. The minimum and the default value is 15 minutes. Translations will be updated every defined time interval once per application load
withUpdateInterval(900)
Advanced Features
Real-time Preview
All the translations that are done in the Editor can be shown in your version of the application in real-time. View the translations already made and the ones you're currently typing in.
Translations update interval in seconds. The minimum and the default value is 15 minutes. Translations will be updated every defined time interval once per application load
withUpdateInterval(900)
Crowdin Authorization is required for Real-Time Preview feature. Create connection using Activity/Fragment method inMainActivity class:
overridefunonDestroy() {
super.onDestroy()
// Close connection with Crowdin.Crowdin.disconnectRealTimeUpdates()
}
To use this feature you also need to wrap context for your activities. See Setup.
OAuth redirect URL should match your App scheme. For example, 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.
Screenshots
Enable if you want all the screenshots made in the application to be automatically sent to your Crowdin project with tagged strings. This will provide 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)
To enable the Screenshots feature follow these instructions:
Add the following code to the Application class:
Kotlin
overridefunonCreate() {
super.onCreate()
Crowdin.init(applicationContext,
CrowdinConfig.Builder()
.withDistributionHash(your_distribution_hash)
.withScreenshotEnabled()
.withSourceLanguage(source_language)
.withAuthConfig(AuthConfig(client_id, client_secret, organization_name, request_auth_dialog))
.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)
Java
@OverrideprotectedvoidonCreate(BundlesavedInstanceState) {
super.onCreate(savedInstanceState);
Crowdin.init(this,
newCrowdinConfig.Builder()
.withDistributionHash(your_distribution_hash)
.withScreenshotEnabled()
.withSourceLanguage(source_language)
.withAuthConfig(newAuthConfig(client_id, client_secret, organization_name, request_auth_dialog))
.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);
Translations update interval in seconds. The minimum and the default value is 15 minutes. Translations will be updated every defined time interval once per application load
withUpdateInterval(900)
Note! Using Crowdin.registerScreenShotContentObserver(this) (system buttons handler) for sending screenshots to Crowdin requires Storage permission for your app.
Crowdin Authorization is required for Screenshots feature. Create connection using Activity/Fragment method in MainActivity class:
To use this feature you also need to wrap context for your activities. See Setup.
OAuth redirect URL should match your App scheme. For example, for scheme <data android:scheme="crowdintest" /> redirect URL in Crowdin should be crowdintest://
File Export Patterns
You can set file export patterns and check existing ones using File Settings. The following placeholders are supported:
Name
Description
%language%
Language name (e.g. Ukrainian)
%two_letters_code%
Language code ISO 639-1 (e.g. uk)
%three_letters_code%
Language code ISO 639-2/T (e.g. ukr)
%locale%
Locale (e.g. uk-UA)
%locale_with_underscore%
Locale (e.g. uk_UA)
%android_code%
Android Locale identifier used to name "values-" directories
Notes
Crowdin works with current locale, if you change locale programmatically use the language plus country format:
Locale("en", "US")
Example of language change in App.kt:
/** * Should be overridden in case you want to change locale programmatically. * For custom language set your application locale taking into account constraints for language and country/region * This should match with `Locale code:` for your custom language on Crowdin platform. * * language - [a-zA-Z]{2,8} * country/region - [a-zA-Z]{2} | [0-9]{3} * * Example: "aa-BB" * */overridefunattachBaseContext(newBase:Context) {
languagePreferences =LanguagePreferences(newBase)
super.attachBaseContext(ContextWrapper(newBase.updateLocale(languagePreferences.getLanguageCode())))
}
For displaying a string, Crowdin tries to find that in dynamic strings, and will use bundled version as fallback. In the other words, Only the new provided strings will be overridden and for the rest the bundled version will be used.
To translate menu items you need to update your onCreateOptionsMenu method:
On each shake event it will trigger Crowdin.forceUpdate(this) method. You can call this method from your app.
Also, there are other public methods in Crowdin class. You can find details in kotlin doc files.
Synchronous mode. You can trigger force upload from Crowdin while launching Splash Activity and after that open Main Activity
In case you have custom TextView with string specified in xml make sure you follow this naming convention PlaceholderTextView otherwise SDK will skip this view during inflating process and it won't be translated.
Limitations
Plurals are supported from Android SDK version 24.
TabItem text added via xml won't be updated. There is workaround: you can store tabItem titles in your string-array and add tabs dynamically.
PreferenceScreen defined via XML not supported.
Contributing
If you want to contribute please read the Contributing guidelines.
Seeking Assistance
If you find any problems or would like to suggest a feature, please feel free to file an issue on Github at Issues Page.
Crowdin Android SDK CDN feature is built with security in mind, which means minimal access possible from the end-user is required.
When you decide to use Crowdin Android SDK, please make sure you’ve made the following information accessible to your end-users.
We use the advantages of Amazon Web Services (AWS) for our computing infrastructure. AWS has ISO 27001 certification and has completed multiple SSAE 16 audits. All the translations are stored at AWS servers.
When you use Crowdin Android SDK CDN – translations are uploaded to Amazon CloudFront to be delivered t
请发表评论