This repository has been archived by the owner on Jan 6, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from wkktoria/multilingual-support
Add multilingual support
- Loading branch information
Showing
16 changed files
with
400 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
src/main/java/io/github/wkktoria/pogodynka/config/LocaleConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package io.github.wkktoria.pogodynka.config; | ||
|
||
import java.util.Locale; | ||
import java.util.ResourceBundle; | ||
|
||
public class LocaleConfig { | ||
private Locale locale; | ||
private ResourceBundle resourceBundle; | ||
|
||
public LocaleConfig() { | ||
this.locale = Locale.getDefault(); | ||
resourceBundle = ResourceBundle.getBundle("pogodynka.resource", locale); | ||
} | ||
|
||
public void setLocale(final Locale locale) { | ||
this.locale = locale; | ||
resourceBundle = ResourceBundle.getBundle("pogodynka.resource", locale); | ||
} | ||
|
||
public ResourceBundle getResourceBundle() { | ||
return resourceBundle; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/main/java/io/github/wkktoria/pogodynka/controller/ResourceController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package io.github.wkktoria.pogodynka.controller; | ||
|
||
import io.github.wkktoria.pogodynka.service.ResourceService; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.util.MissingResourceException; | ||
|
||
public class ResourceController { | ||
private final static Logger LOGGER = LoggerFactory.getLogger(ResourceController.class); | ||
private final ResourceService resourceService; | ||
|
||
public ResourceController(final ResourceService resourceService) { | ||
this.resourceService = resourceService; | ||
} | ||
|
||
public String getByKey(final String key) { | ||
try { | ||
return resourceService.getByKey(key); | ||
} catch (MissingResourceException e) { | ||
LOGGER.error("Cannot get resource: {}", key); | ||
return null; | ||
} | ||
} | ||
} |
Oops, something went wrong.