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

fix:The Build Task for i18n to res folder not working properly #245

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
25 changes: 15 additions & 10 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -201,18 +201,23 @@ dependencies {
}

tasks.register<Copy>("moveFromi18n") {
val locales = listOf("de", "es", "sv", "en-US")
duplicatesStrategy = DuplicatesStrategy.INCLUDE
destinationDir = file("src/main/res")

val locales = listOf("de", "es", "sv", "en-US")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to expand this with the other localizations that are included in Scribe-i18n?

Copy link
Contributor

@MahmoudMabrok MahmoudMabrok Nov 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

val locales = file("src/main/assets/i18n/Scribe-i18n/values").listFiles()
       ?.filter { it.isDirectory }
       ?.map { it.name }
       ?: emptyList()
       

could we use something like this. it will be scalable to all locales we have.

I tried it on workspace and gave me.

[ar, bn, sv, es, en-US, pt, de, fr, mr, ko, ru, hi] ddd
Preparing to move from src/main/assets/i18n/Scribe-i18n/values/ar/ to src/main/res/values-ar/
Preparing to move from src/main/assets/i18n/Scribe-i18n/values/bn/ to src/main/res/values-bn/
Preparing to move from src/main/assets/i18n/Scribe-i18n/values/sv/ to src/main/res/values-sv/
Preparing to move from src/main/assets/i18n/Scribe-i18n/values/es/ to src/main/res/values-es/
Preparing to move from src/main/assets/i18n/Scribe-i18n/values/en-US/ to src/main/res/values/
Preparing to move from src/main/assets/i18n/Scribe-i18n/values/pt/ to src/main/res/values-pt/
Preparing to move from src/main/assets/i18n/Scribe-i18n/values/de/ to src/main/res/values-de/
Preparing to move from src/main/assets/i18n/Scribe-i18n/values/fr/ to src/main/res/values-fr/
Preparing to move from src/main/assets/i18n/Scribe-i18n/values/mr/ to src/main/res/values-mr/
Preparing to move from src/main/assets/i18n/Scribe-i18n/values/ko/ to src/main/res/values-ko/
Preparing to move from src/main/assets/i18n/Scribe-i18n/values/ru/ to src/main/res/values-ru/
Preparing to move from src/main/assets/i18n/Scribe-i18n/values/hi/ to src/main/res/values-hi/

locales.forEach { locale ->
val fromDir = "src/main/assets/i18n/Scribe-i18n/values/$locale/"
val toDir = if (locale == "en-US") "src/main/res/values/" else "src/main/res/values-$locale/"
val sourceDir = file(fromDir)

if (sourceDir.exists()) {
println("Preparing to move from $fromDir to $toDir")
from(fileTree(fromDir))
into(toDir)
duplicatesStrategy = DuplicatesStrategy.INCLUDE
val fromDir = file("src/main/assets/i18n/Scribe-i18n/values/$locale/")
val targetDir = if (locale == "en-US") {
"values"
} else {
"values-$locale"
}

if (fromDir.exists()) {
println("Copying from $fromDir to $targetDir")
from(fromDir) {
into(targetDir)
}
} else {
println("Source directory does not exist: $fromDir")
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/fragment_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@
android:layout_height="wrap_content"
android:layout_gravity="start"
android:layout_marginEnd="4dp"
android:text="@string/app.download.menu_option.download_data"
android:text="@string/app.download.menu_option.scribe_download_data"
android:textSize="18sp"
android:textStyle="bold" />

Expand Down
Loading
Loading