I18nJavaScriptProcessor.java
2.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* javax.jcr.Node
* org.apache.sling.api.resource.ResourceResolver
* org.slf4j.Logger
* org.slf4j.LoggerFactory
*/
package com.adobe.cq.wcm.translation.impl;
import com.adobe.cq.wcm.translation.impl.I18nContentProcessor;
import com.adobe.cq.wcm.translation.impl.I18nStringExtractor;
import java.util.HashMap;
import java.util.HashSet;
import javax.jcr.Node;
import org.apache.sling.api.resource.ResourceResolver;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class I18nJavaScriptProcessor
extends I18nContentProcessor {
private static Logger logger = LoggerFactory.getLogger(I18nJavaScriptProcessor.class);
public I18nJavaScriptProcessor(I18nStringExtractor i18nStringExtractor, HashSet<String> existingI18nStringSet, ResourceResolver resourceResolver) {
super(i18nStringExtractor, existingI18nStringSet, resourceResolver);
}
@Override
boolean processFileForI18nStrings(Node node, HashMap<String, String> i18nStringMap) {
String regEx;
boolean bSave = false;
String fileContent = I18nStringExtractor.getFileContentsFromNode(node);
try {
logger.trace("In function: processFileForI18nStrings for {}", (Object)node.getPath());
regEx = "((CQ)|(Granite))\\.I18n.((get)|(getMessage))\\(\\s*['\"]([^,]*?)['\"]\\)";
if (this.searchAndAddI18nString(fileContent, i18nStringMap, regEx, 7)) {
bSave = true;
}
}
catch (Exception ignored) {
// empty catch block
}
try {
regEx = "((CQ)|(Granite))\\.I18n.((get)|(getMessage))\\(\\s*['\"]([^,]*?)['\"]\\s*,\\s*.*?[^'\"]\\s*\\)";
if (this.searchAndAddI18nString(fileContent, i18nStringMap, regEx, 7)) {
bSave = true;
}
}
catch (Exception ignored) {
// empty catch block
}
try {
regEx = "((CQ)|(Granite))\\.I18n\\.((get)|(getMessage))\\(\\s*[\"'](.*?)[\"'],.*?\\s*[\"'](.*?)['\"]\\s*\\)";
if (this.searchAndAddI18nStringWithComment(fileContent, i18nStringMap, regEx, 7, 8)) {
bSave = true;
}
}
catch (Exception ignored) {
// empty catch block
}
return bSave;
}
@Override
boolean processFileForIncludes(Node node) {
return false;
}
}