mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-08-21 20:22:45 +02:00
parent
6cd77fd7fd
commit
cff7fffe92
|
@ -8,7 +8,9 @@ package com.djrapitops.plan.system.locale.lang;
|
|||
public enum GenericLang implements Lang {
|
||||
YES("Positive", "Yes"),
|
||||
NO("Negative", "No"),
|
||||
UNKNOWN("Unknown", "Unknown");
|
||||
UNKNOWN("Unknown", "Unknown"),
|
||||
TODAY("Today", "'Today'"),
|
||||
YESTERDAY("Yesterday", "'Yesterday'");
|
||||
|
||||
private final String identifier;
|
||||
private final String defaultValue;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.djrapitops.plan.utilities.formatting;
|
||||
|
||||
import com.djrapitops.plan.data.store.objects.DateHolder;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.utilities.formatting.time.*;
|
||||
|
||||
|
@ -33,12 +34,12 @@ public class Formatters {
|
|||
private final PercentageFormatter percentageFormatter;
|
||||
|
||||
@Inject
|
||||
public Formatters(PlanConfig config) {
|
||||
yearLongFormatter = new YearFormatter(config);
|
||||
dayLongFormatter = new DayFormatter(config);
|
||||
clockLongFormatter = new ClockFormatter(config);
|
||||
secondLongFormatter = new SecondFormatter(config);
|
||||
iso8601NoClockLongFormatter = new ISO8601NoClockFormatter(config);
|
||||
public Formatters(PlanConfig config, Locale locale) {
|
||||
yearLongFormatter = new YearFormatter(config, locale);
|
||||
dayLongFormatter = new DayFormatter(config, locale);
|
||||
clockLongFormatter = new ClockFormatter(config, locale);
|
||||
secondLongFormatter = new SecondFormatter(config, locale);
|
||||
iso8601NoClockLongFormatter = new ISO8601NoClockFormatter(config, locale);
|
||||
|
||||
yearFormatter = new DateHolderFormatter(yearLongFormatter);
|
||||
dayFormatter = new DateHolderFormatter(dayLongFormatter);
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
package com.djrapitops.plan.utilities.formatting.time;
|
||||
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
|
||||
|
||||
/**
|
||||
* Formatter for a timestamp that only includes a clock.
|
||||
*
|
||||
|
@ -10,8 +12,8 @@ import com.djrapitops.plan.system.settings.config.PlanConfig;
|
|||
*/
|
||||
public class ClockFormatter extends DateFormatter {
|
||||
|
||||
public ClockFormatter(PlanConfig config) {
|
||||
super(config);
|
||||
public ClockFormatter(PlanConfig config, Locale locale) {
|
||||
super(config, locale);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
package com.djrapitops.plan.utilities.formatting.time;
|
||||
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.locale.lang.GenericLang;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatter;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Locale;
|
||||
import java.util.TimeZone;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
@ -17,9 +18,11 @@ import java.util.concurrent.TimeUnit;
|
|||
public abstract class DateFormatter implements Formatter<Long> {
|
||||
|
||||
protected final PlanConfig config;
|
||||
protected final Locale locale;
|
||||
|
||||
public DateFormatter(PlanConfig config) {
|
||||
public DateFormatter(PlanConfig config, Locale locale) {
|
||||
this.config = config;
|
||||
this.locale = locale;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -28,7 +31,9 @@ public abstract class DateFormatter implements Formatter<Long> {
|
|||
protected String format(long epochMs, String format) {
|
||||
boolean useServerTime = config.isTrue(Settings.USE_SERVER_TIME);
|
||||
String locale = config.getString(Settings.LOCALE);
|
||||
Locale usedLocale = locale.equalsIgnoreCase("default") ? Locale.ENGLISH : Locale.forLanguageTag(locale);
|
||||
java.util.Locale usedLocale = locale.equalsIgnoreCase("default")
|
||||
? java.util.Locale.ENGLISH
|
||||
: java.util.Locale.forLanguageTag(locale);
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat(format, usedLocale);
|
||||
TimeZone timeZone = useServerTime ? TimeZone.getDefault() : TimeZone.getTimeZone("GMT");
|
||||
dateFormat.setTimeZone(timeZone);
|
||||
|
@ -44,9 +49,9 @@ public abstract class DateFormatter implements Formatter<Long> {
|
|||
|
||||
long fromStartOfDay = now % TimeUnit.DAYS.toMillis(1L);
|
||||
if (epochMs > now - fromStartOfDay) {
|
||||
format = format.replace(pattern, "'Today'");
|
||||
format = format.replace(pattern, locale.getString(GenericLang.TODAY));
|
||||
} else if (epochMs > now - TimeUnit.DAYS.toMillis(1L) - fromStartOfDay) {
|
||||
format = format.replace(pattern, "'Yesterday'");
|
||||
format = format.replace(pattern, locale.getString(GenericLang.YESTERDAY));
|
||||
} else if (epochMs > now - TimeUnit.DAYS.toMillis(5L)) {
|
||||
format = format.replace(pattern, "EEEE");
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.djrapitops.plan.utilities.formatting.time;
|
||||
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
|
||||
|
@ -10,8 +11,8 @@ import com.djrapitops.plan.system.settings.config.PlanConfig;
|
|||
*/
|
||||
public class DayFormatter extends DateFormatter {
|
||||
|
||||
public DayFormatter(PlanConfig config) {
|
||||
super(config);
|
||||
public DayFormatter(PlanConfig config, Locale locale) {
|
||||
super(config, locale);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.djrapitops.plan.utilities.formatting.time;
|
||||
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
|
||||
/**
|
||||
|
@ -9,8 +10,8 @@ import com.djrapitops.plan.system.settings.config.PlanConfig;
|
|||
*/
|
||||
public class ISO8601NoClockFormatter extends DateFormatter {
|
||||
|
||||
public ISO8601NoClockFormatter(PlanConfig config) {
|
||||
super(config);
|
||||
public ISO8601NoClockFormatter(PlanConfig config, Locale locale) {
|
||||
super(config, locale);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
package com.djrapitops.plan.utilities.formatting.time;
|
||||
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
|
||||
|
||||
/**
|
||||
* Formatter for timestamp which includes seconds as the smallest entry.
|
||||
*
|
||||
|
@ -10,8 +12,8 @@ import com.djrapitops.plan.system.settings.config.PlanConfig;
|
|||
*/
|
||||
public class SecondFormatter extends DateFormatter {
|
||||
|
||||
public SecondFormatter(PlanConfig config) {
|
||||
super(config);
|
||||
public SecondFormatter(PlanConfig config, Locale locale) {
|
||||
super(config, locale);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.djrapitops.plan.utilities.formatting.time;
|
||||
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
|
||||
|
@ -10,8 +11,8 @@ import com.djrapitops.plan.system.settings.config.PlanConfig;
|
|||
*/
|
||||
public class YearFormatter extends DateFormatter {
|
||||
|
||||
public YearFormatter(PlanConfig config) {
|
||||
super(config);
|
||||
public YearFormatter(PlanConfig config, Locale locale) {
|
||||
super(config, locale);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -312,4 +312,6 @@ WebServer - Notify HTTP User Auth || 网页服务器:已禁用
|
|||
WebServer - Notify no Cert file || 网页服务器:未找到证书密钥存储文件:${0}
|
||||
WebServer FAIL - Port Bind || 未成功初始化网页服务器。端口(${0})是否被占用?
|
||||
WebServer FAIL - SSL Context || 网页服务器:SSL 环境初始化失败。
|
||||
WebServer FAIL - Store Load || 网页服务器:SSL 证书载入失败。
|
||||
WebServer FAIL - Store Load || 网页服务器:SSL 证书载入失败。
|
||||
Yesterday || 'Yesterday'
|
||||
Today || 'Today'
|
|
@ -312,3 +312,5 @@ WebServer - Notify no Cert file || WebServer: Certificate KeySto
|
|||
WebServer FAIL - Port Bind || WebServer was not initialized successfully. Is the port (${0}) in use?
|
||||
WebServer FAIL - SSL Context || WebServer: SSL Context Initialization Failed.
|
||||
WebServer FAIL - Store Load || WebServer: SSL Certificate loading Failed.
|
||||
Yesterday || 'Yesterday'
|
||||
Today || 'Today'
|
|
@ -312,3 +312,5 @@ WebServer - Notify no Cert file || WebServer: Zertifikat KeyStor
|
|||
WebServer FAIL - Port Bind || WebServer wurde nicht erfolgreich initalisiert. Ist der Port (${0}) schon benutzt?
|
||||
WebServer FAIL - SSL Context || WebServer: SSL Context Initialisierung fehlgeschlagen.
|
||||
WebServer FAIL - Store Load || WebServer: SSL Zertifikat konnte nicht geladen werden.
|
||||
Yesterday || 'Yesterday'
|
||||
Today || 'Today'
|
|
@ -312,3 +312,5 @@ WebServer - Notify no Cert file || WebServer: Certificate KeySto
|
|||
WebServer FAIL - Port Bind || WebServer was not initialized successfully. Is the port (${0}) in use?
|
||||
WebServer FAIL - SSL Context || WebServer: SSL Context Initialization Failed.
|
||||
WebServer FAIL - Store Load || WebServer: SSL Certificate loading Failed.
|
||||
Yesterday || 'Yesterday'
|
||||
Today || 'Today'
|
|
@ -311,3 +311,5 @@ WebServer - Notify no Cert file || Web Palvelin: Sertifikaatti A
|
|||
WebServer FAIL - Port Bind || Web Palvelin ei käynnistynyt. Onko portti (${0}) käytössä?
|
||||
WebServer FAIL - SSL Context || Web Palvelin: SSL Kontekstin käynnistys ei onnistunut.
|
||||
WebServer FAIL - Store Load || Web Palvelin: SSL Sertifikaatin lataus ei onnistunut.
|
||||
Yesterday || 'Eilen'
|
||||
Today || 'Tänään'
|
|
@ -312,3 +312,5 @@ WebServer - Notify no Cert file || WebServer: Certificate KeySto
|
|||
WebServer FAIL - Port Bind || WebServer was not initialized successfully. Is the port (${0}) in use?
|
||||
WebServer FAIL - SSL Context || WebServer: SSL Context Initialization Failed.
|
||||
WebServer FAIL - Store Load || WebServer: SSL Certificate loading Failed.
|
||||
Yesterday || 'Yesterday'
|
||||
Today || 'Today'
|
|
@ -312,3 +312,5 @@ WebServer - Notify no Cert file || WebServer: Certificate KeySto
|
|||
WebServer FAIL - Port Bind || WebServer was not initialized successfully. Is the port (${0}) in use?
|
||||
WebServer FAIL - SSL Context || WebServer: SSL Context Initialization Failed.
|
||||
WebServer FAIL - Store Load || WebServer: SSL Certificate loading Failed.
|
||||
Yesterday || 'Yesterday'
|
||||
Today || 'Today'
|
|
@ -312,3 +312,5 @@ WebServer - Notify no Cert file || WebServer: Certificate KeySto
|
|||
WebServer FAIL - Port Bind || WebServer was not initialized successfully. Is the port (${0}) in use?
|
||||
WebServer FAIL - SSL Context || WebServer: SSL Context Initialization Failed.
|
||||
WebServer FAIL - Store Load || WebServer: SSL Certificate loading Failed.
|
||||
Yesterday || 'Yesterday'
|
||||
Today || 'Today'
|
|
@ -312,3 +312,5 @@ WebServer - Notify no Cert file || WebServer: Certificate KeySto
|
|||
WebServer FAIL - Port Bind || WebServer was not initialized successfully. Is the port (${0}) in use?
|
||||
WebServer FAIL - SSL Context || WebServer: SSL Context Initialization Failed.
|
||||
WebServer FAIL - Store Load || WebServer: SSL Certificate loading Failed.
|
||||
Yesterday || 'Yesterday'
|
||||
Today || 'Today'
|
|
@ -312,3 +312,5 @@ WebServer - Notify no Cert file || WebServer: Certificate KeySto
|
|||
WebServer FAIL - Port Bind || WebServer was not initialized successfully. Is the port (${0}) in use?
|
||||
WebServer FAIL - SSL Context || WebServer: SSL Context Initialization Failed.
|
||||
WebServer FAIL - Store Load || WebServer: SSL Certificate loading Failed.
|
||||
Yesterday || 'Yesterday'
|
||||
Today || 'Today'
|
|
@ -312,3 +312,5 @@ WebServer - Notify no Cert file || WebServer: Certificate KeySto
|
|||
WebServer FAIL - Port Bind || WebServer was not initialized successfully. Is the port (${0}) in use?
|
||||
WebServer FAIL - SSL Context || WebServer: SSL Context Initialization Failed.
|
||||
WebServer FAIL - Store Load || WebServer: SSL Certificate loading Failed.
|
||||
Yesterday || 'Yesterday'
|
||||
Today || 'Today'
|
|
@ -312,3 +312,5 @@ WebServer - Notify no Cert file || WebServer: Certificate KeySto
|
|||
WebServer FAIL - Port Bind || WebServer was not initialized successfully. Is the port (${0}) in use?
|
||||
WebServer FAIL - SSL Context || WebServer: SSL Context Initialization Failed.
|
||||
WebServer FAIL - Store Load || WebServer: SSL Certificate loading Failed.
|
||||
Yesterday || 'Yesterday'
|
||||
Today || 'Today'
|
Loading…
Reference in New Issue
Block a user