Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add a setting to restrict which languages get downloaded #12

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions plugin/src/main/java/co/brainly/onesky/OneSkyPlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import org.jetbrains.annotations.TestOnly
* @property apiSecret API secret found on OneSky account's settings page
* @property projectId OneSky's project id for syncing files with
* @property sourceStringFiles list of files to be synced with OneSky
* @property downloadLanguages list of languages to be downloaded, an empty list will download all available languages
* @property downloadBaseLanguage Determines if the plugin should download & replace the base language or not
* @property moduleName appends a prefix to all [sourceStringFiles] for multi-module support, use null to disable
*/
Expand All @@ -25,6 +26,7 @@ open class OneSkyPluginExtension(
var projectId: Int = -1,
var sourceStringFiles: List<String> = emptyList(),
var sourcePath: String = "src/main/res",
var downloadLanguages: List<String> = emptyList(),
var downloadBaseLanguage: Boolean = false,
var moduleName: String? = null
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ open class DownloadTranslationsTask @Inject constructor(
private val projectId = extension.projectId
private val files = extension.sourceStringFiles
private val sourcePath = extension.sourcePath
private val downloadLanguages = extension.downloadLanguages
private val downloadBaseLanguage = extension.downloadBaseLanguage
private val moduleName = extension.moduleName

Expand Down Expand Up @@ -52,6 +53,7 @@ open class DownloadTranslationsTask @Inject constructor(

private fun downloadLanguages(languageListResponse: LanguageListResponse) {
val languages = languageListResponse.data
.filter { downloadLanguages.isEmpty() || it.code in downloadLanguages }
.filter { downloadBaseLanguage || !it.is_base_language }

val totalFiles = languages.size * files.size
Expand Down
Loading