Skip to content

Commit d904bb3

Browse files
author
pmu-axelor
committed
Feature #48815: SCRIPT + TRANSLATION : Prepare a script to retrieve all translation files and copy them onto a folder + a script to replace translated files in their own folder.
1 parent 9d39bec commit d904bb3

2 files changed

+41
-0
lines changed

build.gradle

+38
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,44 @@ task archiveReports(type: Zip) {
8686
destinationDirectory = file("$buildDir/libs")
8787
}
8888

89+
task archiveTranslations(type: Zip) {
90+
def fileName =""
91+
file("modules").traverse(type: groovy.io.FileType.DIRECTORIES, maxDepth: 1) { dir ->
92+
if (new File(dir, "build.gradle").exists() && (new File(dir, "/src/main/resources/i18n").exists())) {
93+
def files = new File(dir, "/src/main/resources/i18n/").listFiles()
94+
for(File file: files) {
95+
if (project.hasProperty("languageCode") && file.getName().contains(project.getProperty("languageCode"))) {
96+
from(file.getPath()){
97+
fileName = dir.getName()+"_"+file.getName()
98+
def newFile = new File(dir, "/src/main/resources/i18n/"+fileName);
99+
rename{newFile.name}
100+
}
101+
}
102+
}
103+
}
104+
}
105+
classifier 'i18n'
106+
includeEmptyDirs = false
107+
destinationDirectory = project.hasProperty("destinationPath") ? file(project.getProperty("destinationPath")) : file("$rootDir/translationsFiles")
108+
}
109+
110+
task copyTranslations (type: Copy){
111+
def filePath = ""
112+
def fileName = ""
113+
if(project.hasProperty("translationsFolderPath") && project.hasProperty("basePath")) {
114+
def sourceDirFiles = new File(project.getProperty("translationsFolderPath")).listFiles()
115+
for(File sourceFile : sourceDirFiles) {
116+
from(sourceFile.getPath()){
117+
def a = sourceFile.getName().split("_")
118+
filePath = a[0] + "/src/main/resources/i18n/";
119+
fileName = a[1]+"_"+a[2]+""
120+
rename{ fileName}
121+
into (filePath)
122+
}
123+
}
124+
into("$rootDir/"+project.getProperty("basePath"))
125+
}
126+
}
89127

90128
task generateChangeLog(type: GenerateAosChangelog) {
91129
group "Axelor application"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
title: "Provided gradle task 'archiveTranslations' to archive translation file for specified language & 'copyTranslations' to update translation files"
3+
type: feature

0 commit comments

Comments
 (0)