|
11 | 11 | import org.apache.commons.lang3.StringEscapeUtils;
|
12 | 12 | import org.apache.commons.lang3.StringUtils;
|
13 | 13 | import org.apache.log4j.Logger;
|
14 |
| -import org.edu_sharing.alfresco.policy.GuestCagePolicy; |
15 | 14 | import org.edu_sharing.alfresco.repository.server.authentication.Context;
|
16 | 15 | import org.edu_sharing.metadataset.v2.*;
|
17 | 16 | import org.edu_sharing.repository.client.tools.CCConstants;
|
|
36 | 35 | import java.text.SimpleDateFormat;
|
37 | 36 | import java.time.Duration;
|
38 | 37 | import java.util.*;
|
| 38 | +import java.util.regex.Matcher; |
| 39 | +import java.util.regex.Pattern; |
39 | 40 | import java.util.stream.Collectors;
|
40 | 41 |
|
41 | 42 |
|
@@ -150,6 +151,7 @@ private String renderTemplate(MetadataTemplate template) throws IllegalArgumentE
|
150 | 151 | html += "<div class='mdsGroup mdsGroup-" + template.getId() + "'>" + "<h2 class='mdsCaption " + template.getId() + "'>" + template.getCaption() + "</h2>" + "<div class='mdsContent'>";
|
151 | 152 | }
|
152 | 153 | String content=template.getHtml();
|
| 154 | + content = replaceI18nStrings(content); |
153 | 155 | for(MetadataWidget srcWidget : mds.getWidgets()){
|
154 | 156 | MetadataWidget widget=mds.findWidgetForTemplateAndCondition(srcWidget.getId(),template.getId(),properties);
|
155 | 157 | int start=content.indexOf("<"+srcWidget.getId());
|
@@ -433,6 +435,22 @@ private String renderTemplate(MetadataTemplate template) throws IllegalArgumentE
|
433 | 435 | return html;
|
434 | 436 | }
|
435 | 437 |
|
| 438 | + private static String replaceI18nStrings(String content) { |
| 439 | + Pattern pattern = Pattern.compile("<i18n ([^>]+)>"); |
| 440 | + Matcher matcher = pattern.matcher(content); |
| 441 | + content = matcher.replaceAll(matchResult -> { |
| 442 | + if(matchResult.groupCount() == 1) { |
| 443 | + try { |
| 444 | + return MetadataHelper.getTranslation(matchResult.group(1)); |
| 445 | + } catch (Exception e) { |
| 446 | + return matchResult.group(1); |
| 447 | + } |
| 448 | + } |
| 449 | + return ""; |
| 450 | + }); |
| 451 | + return content; |
| 452 | + } |
| 453 | + |
436 | 454 | private boolean renderMaterialFeedback(MetadataWidget widget, StringBuffer widgetHtml) {
|
437 | 455 | boolean empty=true;
|
438 | 456 | try {
|
|
0 commit comments