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

Skip to content
Snippets Groups Projects
Commit 9cf61ead authored by Sebastian-Ion TINCU's avatar Sebastian-Ion TINCU
Browse files

EDELIVERY-13528 Part-1 Runtime Translation Using ngx-translate

Clean up code.
parent 3436a1f7
No related tags found
No related merge requests found
Pipeline #192175 failed
...@@ -8,6 +8,14 @@ import org.springframework.stereotype.Component; ...@@ -8,6 +8,14 @@ import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
/**
* Updates locale files on the disk with locales provided by DomiSMP. Any existing locales on the disk matching the
* ones provided in DomiSMP are removed in the process of being replaced.
*
* @since 5.1
* @author Sebastian-Ion TINCU
* @see eu.europa.ec.edelivery.smp.i18n.SMPLocale
*/
@Component @Component
public class SMPLocaleFileSystemInitializer { public class SMPLocaleFileSystemInitializer {
......
...@@ -4,10 +4,22 @@ import org.apache.commons.lang3.StringUtils; ...@@ -4,10 +4,22 @@ import org.apache.commons.lang3.StringUtils;
import java.util.EnumSet; import java.util.EnumSet;
/**
* Locale enumeration for which DomiSMP is providing existing translations.
*
* @since 5.1
* @author Sebastian-Ion TINCU
*/
public enum SMPLocale { public enum SMPLocale {
/**
* The default English locale
*/
EN_US ("en", "English"), EN_US ("en", "English"),
/**
* The Romanian locale
*/
RO_RO ("ro", "Romanian"); RO_RO ("ro", "Romanian");
private final String code; private final String code;
......
...@@ -13,6 +13,12 @@ import java.nio.file.Files; ...@@ -13,6 +13,12 @@ import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.EnumSet; import java.util.EnumSet;
/**
* Service providing operations for managing locales (e.g. updating locales on the disk).
*
* @since 5.1
* @author Sebastian-Ion TINCU
*/
@Service @Service
public class SMPLocaleService { public class SMPLocaleService {
......
...@@ -133,6 +133,10 @@ public class SMPWebAppConfig implements WebMvcConfigurer { ...@@ -133,6 +133,10 @@ public class SMPWebAppConfig implements WebMvcConfigurer {
@Override @Override
public void extendMessageConverters(List<HttpMessageConverter<?>> converters) { public void extendMessageConverters(List<HttpMessageConverter<?>> converters) {
// Configure the resource message converter to allow the direct download of locale files from the disk
LOG.debug("Register ResourceHttpMessageConverter");
converters.add(0, new ResourceHttpMessageConverter());
// Configure Object Mapper with format date as: "2021-12-01T14:52:00Z" // Configure Object Mapper with format date as: "2021-12-01T14:52:00Z"
LOG.debug("Register MappingJackson2HttpMessageConverter"); LOG.debug("Register MappingJackson2HttpMessageConverter");
MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter(); MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
...@@ -148,7 +152,6 @@ public class SMPWebAppConfig implements WebMvcConfigurer { ...@@ -148,7 +152,6 @@ public class SMPWebAppConfig implements WebMvcConfigurer {
dateFormat.setTimeZone(TimeZone.getDefault()); dateFormat.setTimeZone(TimeZone.getDefault());
objectMapper.setDateFormat(dateFormat); objectMapper.setDateFormat(dateFormat);
converters.add(0, new ResourceHttpMessageConverter());
converters.add(1, converter); converters.add(1, converter);
} }
......
...@@ -9,7 +9,9 @@ import org.springframework.web.bind.annotation.*; ...@@ -9,7 +9,9 @@ import org.springframework.web.bind.annotation.*;
import static eu.europa.ec.edelivery.smp.ui.ResourceConstants.CONTEXT_PATH_PUBLIC_LOCALE; import static eu.europa.ec.edelivery.smp.ui.ResourceConstants.CONTEXT_PATH_PUBLIC_LOCALE;
/** /**
* @since * Provides support for returning locale files required by the ngx-translation Angular library.
*
* @since 5.1
* @author Sebastian-Ion TINCU * @author Sebastian-Ion TINCU
*/ */
@RestController @RestController
......
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