Translate file dates

This commit is contained in:
crschnick 2024-09-20 06:39:46 +00:00
parent 0e5d107c3f
commit f893a5c812
13 changed files with 20 additions and 7 deletions

View file

@ -1,5 +1,7 @@
package io.xpipe.app.util;
import io.xpipe.app.core.AppI18n;
import java.text.CharacterIterator;
import java.text.StringCharacterIterator;
import java.time.Duration;
@ -7,7 +9,6 @@ import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.time.temporal.WeekFields;
import java.util.Locale;
import java.util.Objects;
public final class HumanReadableFormat {
@ -57,29 +58,29 @@ public final class HumanReadableFormat {
// not this year
if (x.getYear() != now.getYear()) {
return DAY_MONTH_YEAR.format(x);
return DAY_MONTH_YEAR.withLocale(AppI18n.get().getLoaded().getLocale()).format(x);
}
// not this week
if (getWeekNumber(x) != getWeekNumber(now)) {
return DAY_MONTH.format(x);
return DAY_MONTH.withLocale(AppI18n.get().getLoaded().getLocale()).format(x);
}
// not today
int xDay = x.getDayOfWeek().getValue();
int nowDay = now.getDayOfWeek().getValue();
if (xDay == nowDay - 1) {
return "Yesterday";
return AppI18n.get("yesterday");
}
if (xDay != nowDay) {
return DAY_OF_WEEK.format(x);
return DAY_OF_WEEK.withLocale(AppI18n.get().getLoaded().getLocale()).format(x);
}
return HOUR_MINUTE.format(x);
return HOUR_MINUTE.withLocale(AppI18n.get().getLoaded().getLocale()).format(x);
}
private static int getWeekNumber(LocalDateTime date) {
return date.get(WeekFields.of(Locale.getDefault()).weekOfYear());
return date.get(WeekFields.of(AppI18n.get().getLoaded().getLocale()).weekOfYear());
}
public static String duration(Duration duration) {

View file

@ -517,3 +517,4 @@ gitVault=Git-hvælving
fileBrowser=Fil-browser
confirmAllDeletions=Bekræft alle sletninger
confirmAllDeletionsDescription=Om der skal vises en bekræftelsesdialog for alle sletteoperationer. Som standard er det kun mapper, der kræver en bekræftelse.
yesterday=I går

View file

@ -511,3 +511,4 @@ gitVault=Git-Tresor
fileBrowser=Dateibrowser
confirmAllDeletions=Bestätige alle Löschungen
confirmAllDeletionsDescription=Ob ein Bestätigungsdialog für alle Löschvorgänge angezeigt werden soll. Standardmäßig benötigen nur Verzeichnisse eine Bestätigung.
yesterday=Gestern

View file

@ -516,3 +516,4 @@ gitVault=Git vault
fileBrowser=File browser
confirmAllDeletions=Confirm all deletions
confirmAllDeletionsDescription=Whether to show a confirmation dialog for all delete operations. By default, only directories require a confirmation.
yesterday=Yesterday

View file

@ -498,3 +498,4 @@ gitVault=Bóveda Git
fileBrowser=Navegador de archivos
confirmAllDeletions=Confirmar todos los borrados
confirmAllDeletionsDescription=Si mostrar un diálogo de confirmación para todas las operaciones de borrado. Por defecto, sólo los directorios requieren una confirmación.
yesterday=Ayer

View file

@ -498,3 +498,4 @@ gitVault=Coffre-fort Git
fileBrowser=Navigateur de fichiers
confirmAllDeletions=Confirme toutes les suppressions
confirmAllDeletionsDescription=Affichage ou non d'une boîte de dialogue de confirmation pour toutes les opérations de suppression. Par défaut, seuls les répertoires nécessitent une confirmation.
yesterday=Hier

View file

@ -498,3 +498,4 @@ gitVault=Git vault
fileBrowser=Browser di file
confirmAllDeletions=Conferma tutte le eliminazioni
confirmAllDeletionsDescription=Se mostrare una finestra di conferma per tutte le operazioni di cancellazione. Per impostazione predefinita, solo le directory richiedono una conferma.
yesterday=Ieri

View file

@ -498,3 +498,4 @@ gitVault=Git保管庫
fileBrowser=ファイルブラウザ
confirmAllDeletions=すべての削除を確認する
confirmAllDeletionsDescription=すべての削除操作に対して確認ダイアログを表示するかどうか。デフォルトでは、確認が必要なのはディレクトリだけである。
yesterday=昨日

View file

@ -498,3 +498,4 @@ gitVault=Git kluis
fileBrowser=Bestandsbrowser
confirmAllDeletions=Alle verwijderingen bevestigen
confirmAllDeletionsDescription=Of een bevestigingsvenster moet worden weergegeven voor alle verwijderbewerkingen. Standaard vereisen alleen mappen een bevestiging.
yesterday=Gisteren

View file

@ -498,3 +498,4 @@ gitVault=Cofre do Git
fileBrowser=Navegador de ficheiros
confirmAllDeletions=Confirma todas as eliminações
confirmAllDeletionsDescription=Mostra ou não uma caixa de diálogo de confirmação para todas as operações de eliminação. Por predefinição, apenas as diretorias requerem uma confirmação.
yesterday=Ontem

View file

@ -498,3 +498,4 @@ gitVault=Git vault
fileBrowser=Браузер файлов
confirmAllDeletions=Подтвердите все удаления
confirmAllDeletionsDescription=Показывать ли диалог подтверждения для всех операций удаления. По умолчанию подтверждение требуется только для каталогов.
yesterday=Вчера

View file

@ -499,3 +499,4 @@ gitVault=Git kasası
fileBrowser=Dosya tarayıcısı
confirmAllDeletions=Tüm silme işlemlerini onaylayın
confirmAllDeletionsDescription=Tüm silme işlemleri için bir onay iletişim kutusu gösterilip gösterilmeyeceği. Varsayılan olarak, yalnızca dizinler onay gerektirir.
yesterday=Dün

View file

@ -498,3 +498,4 @@ gitVault=Git 数据库
fileBrowser=文件浏览器
confirmAllDeletions=确认所有删除
confirmAllDeletionsDescription=是否为所有删除操作显示确认对话框。默认情况下,只有目录需要确认。
yesterday=昨天