Skip to content

Commit 036ac5f

Browse files
committed
#22 i18n. Supported static language switching for web UI
This is actually not an i18n solution but a quick fix until next frontend refactoring
1 parent b81c7f1 commit 036ac5f

34 files changed

+1864
-65
lines changed

config/application.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@ server:
33
address: localhost
44
spring:
55
mvc:
6-
locale: en # as of v0.12 supported locales are: en, ru
6+
locale: en # as of v0.12 supported locales are: en, ru
7+
# Uncomment following 3 lines if the above locale is set to 'ru'
8+
# resources:
9+
# static-locations:
10+
# - 'classpath:/static/ru'
711

812
nodes:
913
this:

src/main/resources/static/download/download.component.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,12 @@ function DownloadController($scope, $element, $attrs, $log, $http) {
119119
app.filter('sizeFormatter', function() {
120120
return function(bytes) {
121121
if (!bytes)
122-
return '[н/д]';
122+
return '[n/a]';
123123
if (bytes === 0)
124-
return '0 Байт';
124+
return '0 Bytes';
125125
let k = 1024,
126126
dm = /*decimals ||*/ 2,
127-
sizes = ['Байт', 'КБ', 'МБ', 'ГБ', 'ТБ', 'ПБ', 'ЭБ', 'ЗБ', 'YB'],
127+
sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],
128128
i = Math.floor(Math.log(bytes) / Math.log(k));
129129
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];
130130
};
@@ -133,9 +133,9 @@ app.filter('sizeFormatter', function() {
133133
app.filter('dateFormatter', function () {
134134
return function (utcDateString) {
135135
if (!utcDateString)
136-
return '[н/д]';
136+
return '[n/a]';
137137
let parsedDate = new Date(Date.parse(utcDateString));
138-
return parsedDate.toLocaleString("ru-RU");
138+
return parsedDate.toLocaleString("en-US");
139139
}
140140
});
141141

@@ -146,16 +146,16 @@ app.filter('errorFormatter', function () {
146146
let text;
147147
switch (error.status) {
148148
case 404:
149-
text = 'не найден';
149+
text = 'not found';
150150
break;
151151
case 403:
152-
text = 'запрещён для загрузки';
152+
text = 'access denied';
153153
break;
154154
case 503:
155-
text = 'временно не доступен';
155+
text = 'temporarily unavailable';
156156
break;
157157
default:
158-
text = 'не может быть получен';
158+
text = 'can not be downloaded';
159159
}
160160
text += (' ' + '(HTTP ' + error.status);
161161
if (error.message)

src/main/resources/static/download/download.template.html

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<div>
2-
<button class="btn btn-default navbar-btn navbar-last-item" title="Скачать выбранный лог"
2+
<button class="btn btn-default navbar-btn navbar-last-item" title="Download selected log"
33
ng-click="$ctrl.toggleDialog()" ng-show="$ctrl.isShowingButton">
44
<span class="glyphicon glyphicon-download-alt" aria-hidden="true"></span>
55
</button>
66

77
<div class="panel panel-default" ng-show="$ctrl.isShowingDialog">
88
<div class="panel-body">
99
<div class="dialog-header">
10-
<h4>Контрольная сводка</h4>
10+
<h4>Download Summary</h4>
1111
<div ng-switch="$ctrl.isLoading">
1212
<div ng-switch-when="true">
1313
<div class="loader"></div>
@@ -30,15 +30,15 @@ <h4>Контрольная сводка</h4>
3030
</tr>
3131
<tr ng-show="$ctrl.allMembers.length == 1">
3232
<!-- node may not be specified if selected log is set manually through browser location bar -->
33-
<th scope="row">Узел</th><td>{{$ctrl.file2Download.node || 'текущий'}}</td>
33+
<th scope="row">Node</th><td>{{$ctrl.file2Download.node || 'current'}}</td>
3434
</tr><tr>
35-
<th scope="row">Путь</th><td>{{$ctrl.file2Download.path}}</td>
35+
<th scope="row">Path</th><td>{{$ctrl.file2Download.path}}</td>
3636
</tr><tr>
37-
<th scope="row">Изменен</th><td>{{$ctrl.lastModified | dateFormatter}}</td>
37+
<th scope="row">Changed</th><td>{{$ctrl.lastModified | dateFormatter}}</td>
3838
</tr><tr>
39-
<th scope="row">Размер</th><td>{{$ctrl.currentSize | sizeFormatter}}</td>
39+
<th scope="row">Size</th><td>{{$ctrl.currentSize | sizeFormatter}}</td>
4040
</tr><tr ng-show="$ctrl.lastError">
41-
<th scope="row">Статус</th><td class="text-danger">{{$ctrl.lastError | errorFormatter}}</td>
41+
<th scope="row">Status</th><td class="text-danger">{{$ctrl.lastError | errorFormatter}}</td>
4242
</tr>
4343
</tbody>
4444
</table>
@@ -47,25 +47,25 @@ <h4>Контрольная сводка</h4>
4747
<a ng-href="{{$ctrl.downloadLink}}"
4848
ng-disabled="$ctrl.lastError || $ctrl.isLoading"
4949
ng-click="$ctrl.onDownloadClick()"
50-
class="btn btn-primary" download>Скачать целиком</a>
50+
class="btn btn-primary" download>Download Fully</a>
5151
<a href ng-disabled="$ctrl.lastError || $ctrl.isLoading || ($ctrl.currentSize < 1024*50)"
5252
class="btn btn-primary dropdown-toggle"
5353
data-toggle="dropdown"><span class="caret"></span></a>
5454
<ul class="dropdown-menu">
5555
<li ng-show="$ctrl.currentSize>1024*50" ng-click="$ctrl.closeDialog()">
56-
<a ng-href="{{$ctrl.downloadLink+'&last-kbytes=50'}}" download>Последние 50 КБ</a></li>
56+
<a ng-href="{{$ctrl.downloadLink+'&last-kbytes=50'}}" download>Last 50 KB</a></li>
5757
<li ng-show="$ctrl.currentSize>1024*500" ng-click="$ctrl.closeDialog()">
58-
<a ng-href="{{$ctrl.downloadLink+'&last-kbytes=500'}}" download>Последние 500 КБ</a></li>
58+
<a ng-href="{{$ctrl.downloadLink+'&last-kbytes=500'}}" download>Last 500 KB</a></li>
5959
<li ng-show="$ctrl.currentSize>1024*5120" ng-click="$ctrl.closeDialog()">
60-
<a ng-href="{{$ctrl.downloadLink+'&last-kbytes=5120'}}" download>Последние 5 МБ</a></li>
60+
<a ng-href="{{$ctrl.downloadLink+'&last-kbytes=5120'}}" download>Last 5 MB</a></li>
6161
<li ng-show="$ctrl.currentSize>1024*51200" ng-click="$ctrl.closeDialog()">
62-
<a ng-href="{{$ctrl.downloadLink+'&last-kbytes=51200'}}" download>Последние 50 МБ</a></li>
62+
<a ng-href="{{$ctrl.downloadLink+'&last-kbytes=51200'}}" download>Last 50 MB</a></li>
6363
<li class="divider" ng-show="$ctrl.currentSize>1024*204800"></li>
6464
<li ng-show="$ctrl.currentSize>1024*204800" ng-click="$ctrl.closeDialog()">
65-
<a ng-href="{{$ctrl.downloadLink+'&last-kbytes=204800'}}" download>Последние 200 МБ</a></li>
65+
<a ng-href="{{$ctrl.downloadLink+'&last-kbytes=204800'}}" download>Last 200 MB</a></li>
6666
</ul>
6767
</div>
68-
<a ng-click="$ctrl.closeDialog()" href class="card-link cancel">Отмена</a>
68+
<a ng-click="$ctrl.closeDialog()" href class="card-link cancel">Cancel</a>
6969
</div>
7070
</div>
7171
</div>

src/main/resources/static/general/js/choice-service.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function ChoicesService($http, $location, $log, $rootScope) {
2626
$log.log("Proposed log is unknown among server choices and hence will be added as separate group.");
2727
let logType = detectLogType(proposedLogId);
2828
selectedChoice = {
29-
group: "Указан через URL",
29+
group: "Specified via URL",
3030
title: extractFileName(proposedLogId),
3131
type: logType,
3232
id: proposedLogId

src/main/resources/static/general/js/config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*/
55
app.constant('config', {
66
general: {
7-
appTitle: 'АнаЛ&oacute;г'
7+
appTitle: 'AnaL&oacute;g'
88
},
99

1010
rendering: {

src/main/resources/static/general/js/main-controller.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
app = angular.module("AnaLog", ['ngSanitize', 'ngAnimate', 'ui.select']);
22

33
app.run(function ($rootScope, watchingService) {
4-
$rootScope.watchingLog = "АнаЛ&oacute;г v0.11 (загрузка...)";
4+
$rootScope.watchingLog = "AnaL&oacute;g v0.12 (loading...)";
55
watchingService.connect();
66
});
77

@@ -102,19 +102,19 @@ app.filter('logTypeDetector', function () {
102102
return function (logChoice) {
103103
switch (logChoice.type) {
104104
case 'LOCAL_FILE':
105-
return 'локальный файл';
105+
return 'local file';
106106
case 'NODE':
107-
return 'удалённый файл на узле {node}'.format(logChoice);
107+
return 'remote file on {node} node'.format(logChoice);
108108
case 'COMPOSITE':
109-
return 'композит из {size} {logs}'.format({size: logChoice.includes.length,
109+
return 'composite of {size} {logs}'.format({size: logChoice.includes.length,
110110
logs: quantify(logChoice.includes.length)});
111111
case 'DOCKER':
112-
return 'контейнер в Docker';
112+
return 'Docker container';
113113
case 'KUBERNETES':
114114
case 'K8S':
115-
return 'ресурс в Kubernetes';
115+
return 'Kubernetes resource';
116116
default:
117-
return '[неизвестный тип лога]';
117+
return '[unknown log type]';
118118
}
119119
}
120120
});

src/main/resources/static/general/js/util.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ function arePathsEqual(path1, path2) {
3636

3737
function quantify(count) {
3838
if (count > 1) {
39-
return 'логов';
39+
return 'logs';
4040
} else {
41-
return 'лога';
41+
return 'log';
4242
}
4343
}
4444

src/main/resources/static/index.html

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<meta http-equiv="X-UA-Compatible" content="IE=edge">
66
<meta name="viewport" content="width=device-width, initial-scale=1">
77
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
8-
<title ng-bind-html="watchingLog">АнаЛ&oacute;г v0.11</title>
8+
<title ng-bind-html="watchingLog">AnaL&oacute;g v0.12</title>
99

1010
<script type="text/javascript" src="webjars/jquery/1.11.1/jquery.min.js"></script>
1111
<script type="text/javascript" src="webjars/jquery.scrollto/2.1.2/jquery.scrollTo.min.js"></script>
@@ -47,17 +47,17 @@
4747
<!-- Brand -->
4848
<div class="navbar-header">
4949
<div class="navbar-brand">
50-
<img alt="АнаЛ&oacute;г v0.11" title="АнаЛ&oacute;г v0.11" src="general/img/logo-20-20.png">
50+
<img alt="AnaL&oacute;g v0.12" title="AnaL&oacute;g v0.12" src="general/img/logo-20-20.png">
5151
</div>
5252
</div>
5353
<!-- Watching toggle control -->
5454
<label class="checkbox-inline navbar-text"><input type="checkbox" ng-model="ctrl.onAir">
55-
Отслеживать лог
55+
Follow
5656
</label>
5757
<!-- Choices field-->
5858
<div class="navbar-form navbar-left form-group">
5959
<ui-select ng-model="ctrl.selectedLog" on-select="ctrl.onLogChange()">
60-
<ui-select-match allow-clear="false" placeholder="Имя лога, путь, группа, ...">
60+
<ui-select-match allow-clear="false" placeholder="Log name, path, group, etc.">
6161
<span ng-bind-html="$select.selected.title"></span>
6262
</ui-select-match>
6363
<ui-select-choices group-by="'group'"
@@ -80,11 +80,11 @@
8080
<div class="nav navbar-nav navbar-right">
8181
<!-- Text wrapping control -->
8282
<label class="checkbox-inline navbar-text">
83-
<input type="checkbox" ng-model="ctrl.textWrap">Перенос строк
83+
<input type="checkbox" ng-model="ctrl.textWrap">Wrap Lines
8484
</label>
85-
<!--<p class="navbar-text">Выбран лог: "{{ctrl.selectedLog.title}}"</p>-->
85+
<!--<p class="navbar-text">Selected Log: "{{ctrl.selectedLog.title}}"</p>-->
8686
<!-- Clear button -->
87-
<button class="btn btn-default navbar-btn navbar-last-item" ng-click="ctrl.clear()">Очистить</button>
87+
<button class="btn btn-default navbar-btn navbar-last-item" ng-click="ctrl.clear()">Clear</button>
8888
</div>
8989
</div><!-- /.container-fluid -->
9090
</nav>
@@ -104,7 +104,7 @@
104104

105105
<!-- Scroll down button (auto-hiding) -->
106106
<button type="button" class="btn btn-primary scroll-down-btn ng-hide" hide-upon-auto-scroll
107-
title="Промотать в самый вниз" ng-click="ctrl.scrollDown()">
107+
title="Scroll to bottom" ng-click="ctrl.scrollDown()">
108108
<span class="glyphicon glyphicon-arrow-down" aria-hidden="true"></span>
109109
</button>
110110

src/main/resources/static/notification/notification.constant.js

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,62 +6,63 @@ app.constant('notifications', {
66
//<editor-fold desc="Server Events">
77
serverConnected: {
88
level: 'success',
9-
title: 'Сервер снова доступен',
10-
text: 'Связь восстановлена, можно работать.'
9+
title: 'Server Is Available',
10+
text: 'Connection restored, we can go on working.'
1111
},
1212
serverDisconnected: {
1313
level: 'warning',
14-
title: 'Нет связи с сервером',
15-
text: 'При необходимости слежение продолжится автоматически после восстановления связи.'
14+
title: 'No Connection With Server',
15+
text: 'Log tracking will continue (if necessary) after connection restore.'
1616
},
1717
//</editor-fold>
1818

1919
//<editor-fold desc="Tail Events">
2020
logNotFound: {
2121
level: 'info',
22-
title: 'Лог не найден',
23-
text: "Лог <span class='highlight'>{logPath}</span> не найден. Ожидаю его появления..."
22+
title: 'Log Not Found',
23+
text: "Log <span class='highlight'>{logPath}</span> not found. Waiting for it to appear..."
2424
},
2525
logAppeared: {
2626
level: 'success',
27-
title: 'Лог обнаружен',
28-
text: "Лог <span class='highlight'>{logPath}</span> появился. Отслеживаю его изменения."
27+
title: 'Log Detected',
28+
text: "Log <span class='highlight'>{logPath}</span> has appeared. Following it..."
2929
},
3030
logRotated: {
3131
level: 'info',
32-
title: 'Ротация лога',
33-
text: "Лог <span class='highlight'>{logPath}</span> начал писаться с начала. " +
34-
"Предыдущие записи, вероятно, перенесены в другой лог."
32+
title: 'Log Rotation',
33+
text: "Log <span class='highlight'>{logPath}</span> started to write from scratch. " +
34+
"Perhaps previous records have been moved to another file."
3535
},
3636
logDisappeared: {
3737
level: 'info',
38-
title: 'Лог потерян',
39-
text: "Лог <span class='highlight'>{logPath}</span> пропал. Продолжу отслеживание, когда появится."
38+
title: 'Log Lost',
39+
text: "Log <span class='highlight'>{logPath}</span> has disappeared. The tracking will continue" +
40+
" automatically when the log is back."
4041
},
4142
logTruncated: {
4243
level: 'danger',
43-
title: 'Лог сократился',
44-
text: "Лог <span class='highlight'>{logPath}</span> сократился в размере.<br/>" +
45-
"Дальнейшее отслеживание может быть ошибочным.<br/>В этом случае лучше начать его заново."
44+
title: 'Log Reduced',
45+
text: "Log <span class='highlight'>{logPath}</span> has become shorter.<br/>" +
46+
"Current tracking can become incorrect. Restart it if necessary."
4647
},
4748
unrecognized: {
4849
level: 'warning',
49-
title: 'Сообщение о слежении',
50-
text: "При слежении за логом <span class='highlight'>{logPath}</span> получено сообщение:<br/>" +
50+
title: 'Tracking Notification',
51+
text: "Log <span class='highlight'>{logPath}</span> produced a message:<br/>" +
5152
"<span class='tracking-message'>{message}</span>"
5253
},
5354
//</editor-fold>
5455

5556
//<editor-fold desc="Server Fault(s)">
5657
serverFailure: {
5758
level: 'danger',
58-
title: 'Сообщение от сервера',
59-
text: "Отслеживание прекращено из-за ошибки:<br/><span class='failure-message'>{message}</span>"
59+
title: 'Server Message',
60+
text: "Tracking has been stopped because of error:<br/><span class='failure-message'>{message}</span>"
6061
},
6162
choicesNotFound: {
6263
level: 'danger',
63-
title: 'Сбой на сервере',
64-
text: "Не удалось получить варианты логов из-за ошибки:<br/>" +
64+
title: 'Server Failure',
65+
text: "Couldn't fetch log choices because of error:<br/>" +
6566
"<span class='failure-message'>{message}</span>"
6667
}
6768
//</editor-fold>

0 commit comments

Comments
 (0)