Skip to content

Commit

Permalink
Resolved merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
rmathis committed Sep 24, 2018
2 parents 56bf45c + 0d10c77 commit 0dcc1c2
Show file tree
Hide file tree
Showing 144 changed files with 2,819 additions and 866 deletions.
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pipeline {
}
}
steps {
sh '''./gradlew docker
sh '''./gradlew docker -x test
'''
}
}
Expand Down
1 change: 1 addition & 0 deletions backend/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ dependencies {

//Swagger
compile 'io.springfox:springfox-swagger2:2.9.2'
compile 'io.springfox:springfox-swagger-ui:2.9.2'

testCompile "org.springframework.boot:spring-boot-starter-test"
testCompile "org.spockframework:spock-core:1.1-groovy-2.4"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.Collections;
import java.util.HashSet;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import java.util.Set;
import java.util.stream.Collectors;

/**
* @author Bill Smith (wsmith@unicon.net)
Expand All @@ -22,4 +28,33 @@ public class InternationalizationMessagesController {
public ResponseEntity<?> getAll(Locale locale) {
return ResponseEntity.ok(messageSource.getMessagesMap(locale));
}

@GetMapping(value = "/available")
public ResponseEntity<?> getAvailableLocales() {
Set<ResourceBundle> supportedLocaleResourceBundles = getResourceBundles();
Set<Locale> supportedLocales = supportedLocaleResourceBundles
.stream()
.map(ResourceBundle::getLocale)
.collect(Collectors.toSet());
return ResponseEntity.ok(supportedLocales);
}

/**
* Get all available resource bundles in i18n/messages that matches a locale supported by this JRE.
*
* @return a set of resource bundles for supported locales for this system
*/
private Set<ResourceBundle> getResourceBundles() {
Set<ResourceBundle> resourceBundles = new HashSet<>();

for (Locale locale : Locale.getAvailableLocales()) {
try {
resourceBundles.add(ResourceBundle.getBundle("i18n/messages", locale));
} catch (MissingResourceException e) {
// do nothing
}
}

return Collections.unmodifiableSet(resourceBundles);
}
}
Loading

0 comments on commit 0dcc1c2

Please sign in to comment.