Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit c7c80818 authored by Joze RIHTARSIC's avatar Joze RIHTARSIC
Browse files

Pull request #116: [EDELIVERY-13857] [URGENT] Fix docker image language...

Pull request #116: [EDELIVERY-13857] [URGENT] Fix docker image language initialization and rename user "Alerts" to "My Alerts"

Merge in EDELIVERY/smp from EDELIVERY-13857-rename-user-settings-alert-page-to-my-alerts to development

* commit '2daa053c':
  [EDELIVERY-13857] [URGENT] Fix docker image language initialization and rename user "Alerts" to "My Alerts"
parents af95760b 2daa053c
No related branches found
No related tags found
No related merge requests found
Pipeline #200939 failed
...@@ -844,7 +844,7 @@ ...@@ -844,7 +844,7 @@
"navigation.label.user.settings.profile": "Profile", "navigation.label.user.settings.profile": "Profile",
"navigation.label.user.settings.access.tokens": "Access Tokens", "navigation.label.user.settings.access.tokens": "Access Tokens",
"navigation.label.user.settings.certificates": "Certificate", "navigation.label.user.settings.certificates": "Certificate",
"navigation.label.user.settings.alerts": "Alerts", "navigation.label.user.settings.alerts": "My alerts",
"navigation.label.user.settings.membership": "Membership", "navigation.label.user.settings.membership": "Membership",
"navigation.tooltip.search.resources": "Search registered resources", "navigation.tooltip.search.resources": "Search registered resources",
"navigation.tooltip.search.tools": "Search tools", "navigation.tooltip.search.tools": "Search tools",
......
...@@ -844,7 +844,7 @@ ...@@ -844,7 +844,7 @@
"navigation.label.user.settings.profile": "Profil", "navigation.label.user.settings.profile": "Profil",
"navigation.label.user.settings.access.tokens": "Token-uri de Acces", "navigation.label.user.settings.access.tokens": "Token-uri de Acces",
"navigation.label.user.settings.certificates": "Certificate", "navigation.label.user.settings.certificates": "Certificate",
"navigation.label.user.settings.alerts": "Alerte", "navigation.label.user.settings.alerts": "Alertele mele",
"navigation.label.user.settings.membership": "Calitate de Membru", "navigation.label.user.settings.membership": "Calitate de Membru",
"navigation.tooltip.search.resources": "Cauta resurse inregistrate", "navigation.tooltip.search.resources": "Cauta resurse inregistrate",
"navigation.tooltip.search.tools": "Cauta resurse inregistrate", "navigation.tooltip.search.tools": "Cauta resurse inregistrate",
......
...@@ -21,12 +21,9 @@ public class SMPLocaleFileSystemInitializer { ...@@ -21,12 +21,9 @@ public class SMPLocaleFileSystemInitializer {
private static final SMPLogger LOG = SMPLoggerFactory.getLogger(SMPLocaleFileSystemInitializer.class); private static final SMPLogger LOG = SMPLoggerFactory.getLogger(SMPLocaleFileSystemInitializer.class);
private final ConfigurationService configurationService;
private final SMPLocaleService smpLocaleService; private final SMPLocaleService smpLocaleService;
public SMPLocaleFileSystemInitializer(ConfigurationService configurationService, SMPLocaleService smpLocaleService) { public SMPLocaleFileSystemInitializer(SMPLocaleService smpLocaleService) {
this.configurationService = configurationService;
this.smpLocaleService = smpLocaleService; this.smpLocaleService = smpLocaleService;
} }
......
package eu.europa.ec.edelivery.smp.services; package eu.europa.ec.edelivery.smp.services;
import eu.europa.ec.edelivery.smp.config.enums.SMPEnvPropertyEnum;
import eu.europa.ec.edelivery.smp.i18n.SMPLocale; import eu.europa.ec.edelivery.smp.i18n.SMPLocale;
import eu.europa.ec.edelivery.smp.logging.SMPLogger; import eu.europa.ec.edelivery.smp.logging.SMPLogger;
import eu.europa.ec.edelivery.smp.logging.SMPLoggerFactory; import eu.europa.ec.edelivery.smp.logging.SMPLoggerFactory;
...@@ -11,6 +12,7 @@ import java.io.File; ...@@ -11,6 +12,7 @@ import java.io.File;
import java.io.InputStream; import java.io.InputStream;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.util.EnumSet; import java.util.EnumSet;
/** /**
...@@ -32,6 +34,10 @@ public class SMPLocaleService { ...@@ -32,6 +34,10 @@ public class SMPLocaleService {
public Path getLocaleFile(SMPLocale locale) { public Path getLocaleFile(SMPLocale locale) {
File localeFolder = configurationService.getLocaleFolder(); File localeFolder = configurationService.getLocaleFolder();
if (!localeFolder.exists() && !localeFolder.mkdirs()) {
LOG.error("Failed to create locale folder [{}]", localeFolder);
return null;
}
return new File(localeFolder, locale.getCode() + ".json").toPath().toAbsolutePath(); return new File(localeFolder, locale.getCode() + ".json").toPath().toAbsolutePath();
} }
...@@ -47,10 +53,16 @@ public class SMPLocaleService { ...@@ -47,10 +53,16 @@ public class SMPLocaleService {
Resource resource = getLocaleResource(locale); Resource resource = getLocaleResource(locale);
if (resource.exists()) { if (resource.exists()) {
Path localeFile = getLocaleFile(locale); Path localeFile = getLocaleFile(locale);
if (localeFile == null) {
LOG.warn("Can not generate 'locale/language' file [{}]! Check if local folder defined in property [{}] " +
"has writing permissions and the folder exists", localeFile, SMPEnvPropertyEnum.LOCALE_FOLDER.getProperty());
return;
}
if (Files.exists(localeFile)) {
LOG.warn("Language file [{}] already exists, and it will be replaced with up-to-date translations", localeFile);
}
try(InputStream inputStream = resource.getInputStream()) { try(InputStream inputStream = resource.getInputStream()) {
Files.deleteIfExists(localeFile); Files.copy(inputStream, localeFile, StandardCopyOption.REPLACE_EXISTING);
Files.copy(inputStream, localeFile);
} catch (Exception e) { } catch (Exception e) {
LOG.error("An error occurred while updating locale file [{}]", localeFile, e); LOG.error("An error occurred while updating locale file [{}]", localeFile, e);
} }
......
...@@ -35,12 +35,11 @@ public class LocaleController { ...@@ -35,12 +35,11 @@ public class LocaleController {
@ResponseBody @ResponseBody
public Resource getLocale(@PathVariable("code") String code) { public Resource getLocale(@PathVariable("code") String code) {
Path langResourcePath = smpLocaleService.getLocaleFile(SMPLocale.fromCodeDefaultingToEnglish(code)); Path langResourcePath = smpLocaleService.getLocaleFile(SMPLocale.fromCodeDefaultingToEnglish(code));
if (langResourcePath.toFile().exists()) { if (langResourcePath != null && langResourcePath.toFile().exists()) {
LOG.debug("Returning locale file [{}]", langResourcePath.toAbsolutePath()); LOG.debug("Returning locale file [{}]", langResourcePath.toAbsolutePath());
return new FileSystemResource(langResourcePath); return new FileSystemResource(langResourcePath);
} else { } else {
LOG.warn("Locale file [{}] does not exist. Return default translation!", langResourcePath.toAbsolutePath()); LOG.warn("Locale file [{}] does not exist. Return default translation!", langResourcePath.toAbsolutePath());
ClassPathResource defResource = new ClassPathResource(DEFAULT_LOCALE_RESOURCE); ClassPathResource defResource = new ClassPathResource(DEFAULT_LOCALE_RESOURCE);
if (defResource.exists()) { if (defResource.exists()) {
return defResource; return defResource;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment