Implements database, adds profiles
This commit is contained in:
38
api/src/main/java/ch/gtache/fro/Translated.java
Normal file
38
api/src/main/java/ch/gtache/fro/Translated.java
Normal file
@@ -0,0 +1,38 @@
|
||||
package ch.gtache.fro;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Represents a translated object
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface Translated {
|
||||
|
||||
/**
|
||||
* Returns the translations
|
||||
*
|
||||
* @return The translations
|
||||
*/
|
||||
Map<Locale, String> translations();
|
||||
|
||||
/**
|
||||
* Translates the object using the given locale
|
||||
*
|
||||
* @param locale The locale
|
||||
* @return The translated string
|
||||
*/
|
||||
default String translate(final Locale locale) {
|
||||
return translations().get(locale);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Translates the object using the default locale
|
||||
*
|
||||
* @return The translated string
|
||||
*/
|
||||
default String translate() {
|
||||
return translate(Locale.getDefault());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user