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 @@
"navigation.label.user.settings.profile": "Profile",
"navigation.label.user.settings.access.tokens": "Access Tokens",
"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.tooltip.search.resources": "Search registered resources",
"navigation.tooltip.search.tools": "Search tools",
......
......@@ -844,7 +844,7 @@
"navigation.label.user.settings.profile": "Profil",
"navigation.label.user.settings.access.tokens": "Token-uri de Acces",
"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.tooltip.search.resources": "Cauta resurse inregistrate",
"navigation.tooltip.search.tools": "Cauta resurse inregistrate",
......
......@@ -21,12 +21,9 @@ public class SMPLocaleFileSystemInitializer {
private static final SMPLogger LOG = SMPLoggerFactory.getLogger(SMPLocaleFileSystemInitializer.class);
private final ConfigurationService configurationService;
private final SMPLocaleService smpLocaleService;
public SMPLocaleFileSystemInitializer(ConfigurationService configurationService, SMPLocaleService smpLocaleService) {
this.configurationService = configurationService;
public SMPLocaleFileSystemInitializer(SMPLocaleService smpLocaleService) {
this.smpLocaleService = smpLocaleService;
}
......
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.logging.SMPLogger;
import eu.europa.ec.edelivery.smp.logging.SMPLoggerFactory;
......@@ -11,6 +12,7 @@ import java.io.File;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.util.EnumSet;
/**
......@@ -32,6 +34,10 @@ public class SMPLocaleService {
public Path getLocaleFile(SMPLocale locale) {
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();
}
......@@ -47,10 +53,16 @@ public class SMPLocaleService {
Resource resource = getLocaleResource(locale);
if (resource.exists()) {
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()) {
Files.deleteIfExists(localeFile);
Files.copy(inputStream, localeFile);
Files.copy(inputStream, localeFile, StandardCopyOption.REPLACE_EXISTING);
} catch (Exception e) {
LOG.error("An error occurred while updating locale file [{}]", localeFile, e);
}
......
......@@ -35,12 +35,11 @@ public class LocaleController {
@ResponseBody
public Resource getLocale(@PathVariable("code") String 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());
return new FileSystemResource(langResourcePath);
} else {
LOG.warn("Locale file [{}] does not exist. Return default translation!", langResourcePath.toAbsolutePath());
ClassPathResource defResource = new ClassPathResource(DEFAULT_LOCALE_RESOURCE);
if (defResource.exists()) {
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