Skip to content

Commit aa70aea

Browse files
committed
truncate source suffix in target resource files
1 parent 0f80bfc commit aa70aea

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

gp-maven-plugin/src/main/java/com/ibm/g11n/pipeline/maven/GPDownloadMojo.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
132132
if (outputSrcLang) {
133133
if (bdlLangs.contains(srcLang)) {
134134
exportLanguageResource(client, bf, srcLang, outDir,
135-
outContentOpt, bundleLayout, langIdStyle, langMap);
135+
outContentOpt, bundleLayout, langIdStyle, langMap, srcLang);
136136
} else {
137137
getLog().warn("The specified source language (" + srcLang
138138
+ ") does not exist in the bundle:" + bundleId);
@@ -142,7 +142,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
142142
for (String tgtLang: tgtLangs) {
143143
if (bdlLangs.contains(tgtLang)) {
144144
exportLanguageResource(client, bf, tgtLang, outDir,
145-
outContentOpt, bundleLayout, langIdStyle, langMap);
145+
outContentOpt, bundleLayout, langIdStyle, langMap, srcLang);
146146
} else {
147147
getLog().warn("The specified target language (" + tgtLang
148148
+ ") does not exist in the bundle:" + bundleId);
@@ -154,11 +154,17 @@ public void execute() throws MojoExecutionException, MojoFailureException {
154154

155155
private void exportLanguageResource(ServiceClient client, SourceBundleFile bf, String language,
156156
File outBaseDir, OutputContentOption outContntOpt, BundleLayout bundleLayout,
157-
LanguageIdStyle langIdStyle, Map<String, String> langMap)
157+
LanguageIdStyle langIdStyle, Map<String, String> langMap, String srcLang)
158158
throws MojoFailureException {
159159
String srcFileName = bf.getFile().getName();
160160
String relPath = bf.getRelativePath();
161-
161+
162+
// truncate source suffix from target resource files
163+
int extensionIndex = srcFileName.lastIndexOf('.');
164+
String extension = (extensionIndex > 0) ? srcFileName.substring(extensionIndex) : "";
165+
int srcSuffixIndex = (langMap.containsKey(srcLang)) ? srcFileName.lastIndexOf("_" + langMap.get(srcLang)) : srcFileName.lastIndexOf("_" + srcLang);
166+
srcFileName = (srcSuffixIndex > 0) ? srcFileName.substring(0,srcSuffixIndex) + extension : srcFileName;
167+
162168
File outputFile = null;
163169

164170
switch (bundleLayout) {

0 commit comments

Comments
 (0)