mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-20 07:02:21 +01:00
Fixed some issues with translation
This commit is contained in:
parent
ff1310a01e
commit
10fa9dd535
@ -20,7 +20,6 @@ import com.djrapitops.plan.settings.locale.lang.HtmlLang;
|
||||
import com.djrapitops.plan.settings.locale.lang.Lang;
|
||||
import com.djrapitops.plan.storage.file.FileResource;
|
||||
import com.djrapitops.plan.storage.file.PlanFiles;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@ -119,24 +118,20 @@ public class Locale extends HashMap<Lang, Message> {
|
||||
HtmlLang.values()
|
||||
};
|
||||
|
||||
List<String> replace = new ArrayList<>();
|
||||
List<String> with = new ArrayList<>();
|
||||
|
||||
TranslatedString translated = new TranslatedString(from);
|
||||
Arrays.stream(langs).flatMap(Arrays::stream)
|
||||
// Longest first so that entries that contain each other don't partially replace.
|
||||
.sorted((one, two) -> Integer.compare(
|
||||
two.getIdentifier().length(),
|
||||
one.getIdentifier().length()
|
||||
))
|
||||
.forEach(lang -> getNonDefault(lang).ifPresent(replacement -> {
|
||||
replace.add(lang.getDefault());
|
||||
with.add(replacement.toString());
|
||||
}));
|
||||
.forEach(lang -> getNonDefault(lang).ifPresent(replacement ->
|
||||
translated.translate(lang.getDefault(), replacement.toString()))
|
||||
);
|
||||
|
||||
String translated = StringUtils.replaceEach(from, replace.toArray(new String[0]), with.toArray(new String[0]));
|
||||
StringBuilder complete = new StringBuilder(translated.length());
|
||||
|
||||
String[] parts = scripts.split(translated);
|
||||
String[] parts = scripts.split(translated.toString());
|
||||
for (int i = 0; i < parts.length; i++) {
|
||||
complete.append(parts[i]);
|
||||
if (i < parts.length - 1) {
|
||||
|
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* This file is part of Player Analytics (Plan).
|
||||
*
|
||||
* Plan is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License v3 as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Plan is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.djrapitops.plan.settings.locale;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
/**
|
||||
* Utility for translating String.
|
||||
* <p>
|
||||
* Improves performance by avoiding a double for-each loop since this class can be considered final in the lambda
|
||||
* expression in {@link Locale#replaceMatchingLanguage(String)}.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
class TranslatedString {
|
||||
|
||||
private String translating;
|
||||
|
||||
TranslatedString(String translating) {
|
||||
this.translating = translating;
|
||||
}
|
||||
|
||||
public void translate(String replace, String with) {
|
||||
translating = StringUtils.replace(translating, replace, with);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return translating;
|
||||
}
|
||||
|
||||
public int length() {
|
||||
return translating.length();
|
||||
}
|
||||
}
|
@ -77,6 +77,7 @@ public enum HtmlLang implements Lang {
|
||||
LABEL_PER_PLAYER("/ Player"),
|
||||
LABEL_AVG_SESSION_LENGTH("Average Session Length"),
|
||||
TITLE_WEEK_COMPARISON("Week Comparison"),
|
||||
TITLE_TRENDS("Trends for 30 days"),
|
||||
TITLE_TREND("Trend"),
|
||||
COMPARING_7_DAYS("Comparing 7 days"),
|
||||
// Servers tab
|
||||
@ -104,7 +105,6 @@ public enum HtmlLang implements Lang {
|
||||
// Playerbase overview tab
|
||||
TITLE_PLAYERBASE_DEVELOPMENT("Playerbase development"),
|
||||
TITLE_CURRENT_PLAYERBASE("Current Playerbase"),
|
||||
TITLE_TRENDS("Trends for 30 days"),
|
||||
COMPARING_60_DAYS("Comparing 30d ago to Now"),
|
||||
TITLE_30_DAYS_AGO("30 days ago"),
|
||||
TITLE_NOW("Now"),
|
||||
@ -167,6 +167,16 @@ public enum HtmlLang implements Lang {
|
||||
TITLE_SERVER_PLAYTIME("Server Playtime"),
|
||||
LINK_BACK_SERVER("Server page"),
|
||||
SIDE_SERVERS_TITLE("SERVERS"),
|
||||
// Were missing
|
||||
TITLE_SERVER_OVERVIEW("Server Overview"),
|
||||
TITLE_ONLINE_ACTIVITY_OVERVIEW("Online Activity Overview"),
|
||||
PER_DAY("/ Day"),
|
||||
TITLE_WORLD_PLAYTIME("World Playtime"),
|
||||
TITLE_PLAYER_OVERVIEW("Player Overview"),
|
||||
LABEL_LONGEST_SESSION("Longest Session"),
|
||||
LABEL_REGISTERED("Registered"),
|
||||
TITLE_TITLE_PLAYER_PUNCHCARD("Punchcard"),
|
||||
TITLE_ALL_TIME("All Time"),
|
||||
// ----------------------------------
|
||||
// OLD
|
||||
// ----------------------------------
|
||||
|
@ -156,7 +156,7 @@ HTML - TITLE_PLAYERBASE_DEVELOPMENT || 玩家发展
|
||||
HTML - LABEL_PLAYERS_ONLINE || 在线玩家
|
||||
HTML - PLAYERS_TEXT || 玩家
|
||||
HTML - LABEL_PLAYTIME || 游玩时间
|
||||
HTML - TITLE_PUNCH_CARD || 打卡签到 for 30 days
|
||||
HTML - TITLE_GRAPH_PUNCHCARD || 打卡签到 for 30 days
|
||||
HTML - LABEL_REGISTERED || 已注册
|
||||
HTML - TITLE_SEEN_NICKNAMES || 可视昵称
|
||||
HTML - TITLE_SERVER || 服务器
|
||||
@ -246,3 +246,6 @@ Yesterday || '昨天'
|
||||
Today || '今天'
|
||||
HTML - LABEL_FREE_DISK_SPACE || 剩余磁盘空间
|
||||
HTML - TITLE_DISK || 磁盘空间
|
||||
HTML - PER_DAY || / 天
|
||||
HTML - LABEL_REGISTERED || 已注册
|
||||
HTML - TITLE_PLAYER_PUNCHCARD || 打卡签到
|
@ -156,7 +156,7 @@ HTML - TITLE_PLAYERBASE_DEVELOPMENT || Entwicklung der Playerbase
|
||||
HTML - LABEL_PLAYERS_ONLINE || Spieler Online
|
||||
HTML - PLAYERS_TEXT || Spieler
|
||||
HTML - LABEL_PLAYTIME || Spielzeit
|
||||
HTML - TITLE_PUNCH_CARD || Lochkarte for 30 days
|
||||
HTML - TITLE_GRAPH_PUNCHCARD || Lochkarte for 30 days
|
||||
HTML - LABEL_REGISTERED || Registriert
|
||||
HTML - TITLE_SEEN_NICKNAMES || Registrierte Nicknames
|
||||
HTML - TITLE_SERVER || Server
|
||||
@ -245,3 +245,6 @@ Yesterday || 'Gestern'
|
||||
Today || 'Heute'
|
||||
HTML - LABEL_FREE_DISK_SPACE || Freier Festplattenspeicher
|
||||
HTML - TITLE_DISK || Festplattenspeicher
|
||||
HTML - PER_DAY || / Tag
|
||||
HTML - LABEL_REGISTERED || Registriert
|
||||
HTML - TITLE_PLAYER_PUNCHCARD || Lochkarte
|
@ -156,7 +156,7 @@ HTML - TITLE_PLAYERBASE_DEVELOPMENT || Playerbase Development
|
||||
HTML - LABEL_PLAYERS_ONLINE || Players Online
|
||||
HTML - PLAYERS_TEXT || Players
|
||||
HTML - LABEL_PLAYTIME || Playtime
|
||||
HTML - TITLE_PUNCH_CARD || Punchcard for 30 days
|
||||
HTML - TITLE_GRAPH_PUNCHCARD || Punchcard for 30 days
|
||||
HTML - LABEL_REGISTERED || Registered
|
||||
HTML - TITLE_SEEN_NICKNAMES || Seen Nicknames
|
||||
HTML - TITLE_SERVER || Server
|
||||
@ -245,3 +245,6 @@ Yesterday || 'Yesterday'
|
||||
Today || 'Today'
|
||||
HTML - LABEL_FREE_DISK_SPACE || Free Disk Space
|
||||
HTML - TITLE_DISK || Disk space
|
||||
HTML - PER_DAY || / Day
|
||||
HTML - LABEL_REGISTERED || Registered
|
||||
HTML - TITLE_PLAYER_PUNCHCARD || Punchcard
|
@ -332,3 +332,6 @@ WebServer FAIL - Port Bind || Web Palvelin ei käynnistynyt
|
||||
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'
|
||||
HTML - PER_DAY || / Päivä
|
||||
HTML - LABEL_REGISTERED || Rekisteröitynyt
|
||||
HTML - TITLE_PLAYER_PUNCHCARD || Reikäkortti
|
@ -156,7 +156,7 @@ HTML - TITLE_PLAYERBASE_DEVELOPMENT || Évolution de la base de joue
|
||||
HTML - LABEL_PLAYERS_ONLINE || Joueurs en ligne
|
||||
HTML - PLAYERS_TEXT || Joueurs
|
||||
HTML - LABEL_PLAYTIME || Temps de jeu
|
||||
HTML - TITLE_PUNCH_CARD || Carte perforée for 30 days
|
||||
HTML - TITLE_GRAPH_PUNCHCARD || Carte perforée for 30 days
|
||||
HTML - LABEL_REGISTERED || Inscription
|
||||
HTML - TITLE_SEEN_NICKNAMES || Surnoms Vus
|
||||
HTML - TITLE_SERVER || Serveur
|
||||
@ -245,3 +245,6 @@ Yesterday || 'Hier'
|
||||
Today || 'Aujourd''hui'
|
||||
HTML - LABEL_FREE_DISK_SPACE || Espace disque disponible
|
||||
HTML - TITLE_DISK || Espace disque
|
||||
HTML - PER_DAY || / Jour
|
||||
HTML - LABEL_REGISTERED || Inscription
|
||||
HTML - TITLE_PLAYER_PUNCHCARD || Carte perforée
|
@ -154,7 +154,7 @@ HTML - TITLE_PLAYERBASE_DEVELOPMENT || 登録されているプレ
|
||||
HTML - LABEL_PLAYERS_ONLINE || オンラインのプレイヤー
|
||||
HTML - PLAYERS_TEXT || プレイヤー
|
||||
HTML - LABEL_PLAYTIME || プレイ時間
|
||||
HTML - TITLE_PUNCH_CARD || パンチボード for 30 days
|
||||
HTML - TITLE_GRAPH_PUNCHCARD || パンチボード for 30 days
|
||||
HTML - LABEL_REGISTERED || 登録
|
||||
HTML - TITLE_SEEN_NICKNAMES || ニックネーム一覧
|
||||
HTML - TITLE_SERVER || サーバー
|
||||
@ -246,3 +246,6 @@ WebServer - Notify no Cert file || Webサーバー: 以下のパ
|
||||
WebServer FAIL - Port Bind || Webサーバーの初期化が正常に終了しませんでした。ポート番号(${0})は使用されていませんか?
|
||||
WebServer FAIL - SSL Context || Webサーバー: SSLコンテキストの初期化に失敗しました。
|
||||
WebServer FAIL - Store Load || Webサーバー: SSL証明書のロードに失敗しました
|
||||
HTML - PER_DAY || /日
|
||||
HTML - LABEL_REGISTERED || 登録
|
||||
HTML - TITLE_PLAYER_PUNCHCARD || パンチボード
|
@ -156,7 +156,7 @@ HTML - TITLE_PLAYERBASE_DEVELOPMENT || Desenvolvimento da base de Jo
|
||||
HTML - LABEL_PLAYERS_ONLINE || Jogadores Online
|
||||
HTML - PLAYERS_TEXT || Jogadores
|
||||
HTML - LABEL_PLAYTIME || Tempo de Jogo
|
||||
HTML - TITLE_PUNCH_CARD || Cartão Perfurado for 30 days
|
||||
HTML - TITLE_GRAPH_PUNCHCARD || Cartão Perfurado for 30 days
|
||||
HTML - LABEL_REGISTERED || Registrados
|
||||
HTML - TITLE_SEEN_NICKNAMES || Nicks Vistos
|
||||
HTML - TITLE_SERVER || Servidor
|
||||
@ -245,3 +245,6 @@ Yesterday || 'Ontem'
|
||||
Today || 'Hoje'
|
||||
HTML - LABEL_FREE_DISK_SPACE || Espaço de Disco Livre
|
||||
HTML - TITLE_DISK || Espaço de disco
|
||||
HTML - PER_DAY || / Dia
|
||||
HTML - LABEL_REGISTERED || Registrados
|
||||
HTML - TITLE_PLAYER_PUNCHCARD || Cartão Perfurado
|
@ -156,7 +156,7 @@ HTML - TITLE_PLAYERBASE_DEVELOPMENT || Oyuncu Etkinlik Grafiği
|
||||
HTML - LABEL_PLAYERS_ONLINE || Oyuncu Çevrimiçi
|
||||
HTML - PLAYERS_TEXT || Oyuncular
|
||||
HTML - LABEL_PLAYTIME || Oyun Süresi
|
||||
HTML - TITLE_PUNCH_CARD || Punchcard for 30 days
|
||||
HTML - TITLE_GRAPH_PUNCHCARD || Punchcard for 30 days
|
||||
HTML - LABEL_REGISTERED || Kayıtlı
|
||||
HTML - TITLE_SEEN_NICKNAMES || Görülen takma adlar
|
||||
HTML - TITLE_SERVER || Sunucu
|
||||
@ -242,3 +242,6 @@ WebServer FAIL - Port Bind || Web Sunucusu başarıyla baş
|
||||
WebServer FAIL - SSL Context || WebServer: SSL İçeriği Başlatma Başarısız Oldu.
|
||||
WebServer FAIL - Store Load || WebServer: SSL Sertifikası yüklenirken sorun oluştu.
|
||||
Yesterday || 'Dün'
|
||||
HTML - PER_DAY || / Gün
|
||||
HTML - LABEL_REGISTERED || Kayıtlı
|
||||
HTML - TITLE_PLAYER_PUNCHCARD || Punchcard
|
@ -150,7 +150,7 @@ function loadServerAccordion(json, error) {
|
||||
return;
|
||||
}
|
||||
|
||||
serverTable = $("#server-overview").find("#tableServerAccordion").find("tbody");
|
||||
serverTable = $("#server-overview").find("#tableSAccordion").find("tbody");
|
||||
|
||||
var servers = json.servers;
|
||||
|
||||
@ -204,9 +204,9 @@ function createServerAccordionTitle(i, server) {
|
||||
|
||||
function createServerAccordionBody(i, server) {
|
||||
|
||||
return '<tr class="collapse" data-parent="#tableServerAccordion" id="server_t_' + i + '">' +
|
||||
return '<tr class="collapse" data-parent="#tableSAccordion" id="server_t_' + i + '">' +
|
||||
'<td colspan="4">' +
|
||||
'<div class="collapse row" data-parent="#tableServerAccordion" id="server_t_' + i + '">' +
|
||||
'<div class="collapse row" data-parent="#tableSAccordion" id="server_t_' + i + '">' +
|
||||
'<div class="col-xs-12 col-sm-12 col-md-6 col-lg-6">' +
|
||||
(server.operator ? '<p><i class="col-blue fab fa-fw fa-superpowers"></i> Operator</p>' : '') +
|
||||
(server.banned ? '<p><i class="col-red fas fa-fw fa-gavel"></i> Banned</p>' : '') +
|
||||
|
@ -229,7 +229,7 @@
|
||||
<table class="table table-striped scrollbar mb-0">
|
||||
<thead class="bg-green">
|
||||
<tr>
|
||||
<th><i class="fa fa-fw fa-globe"></i> Geolocation</th>
|
||||
<th><i class="fa fa-fw fa-globe"></i> Country</th>
|
||||
<th><i class="far fa-fw fa-clock"></i> Last Connected</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@ -518,7 +518,7 @@
|
||||
<small>Click to expand</small></span></h6>
|
||||
</div>
|
||||
<div class="scrollbar">
|
||||
<table class="table" id="tableServerAccordion">
|
||||
<table class="table" id="tableSAccordion">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><i class="fa fa-fw fa-server"></i> Server</th>
|
||||
|
Loading…
Reference in New Issue
Block a user