Merge branch 'master' into simon/angular-universal
* master: Update list of supported locales Add one more fix to nginx.conf for i18n Remove unused i18n tags in frontend/src/index.html Update translations from Transifex Enable 'fr' locale for French Corrected some missing spaces on transactions page and a blank render bug when confirmation time is below 1 minute. Implement i18n support in frontend using Angular + Transifex + NGINX # Conflicts: # frontend/src/app/app.constants.ts # frontend/sync-assets.js
This commit is contained in:
@@ -18,17 +18,6 @@ export class TimeSinceComponent implements OnInit, OnChanges, OnDestroy {
|
||||
private ref: ChangeDetectorRef,
|
||||
private stateService: StateService,
|
||||
) {
|
||||
if (document.body.clientWidth < 768) {
|
||||
this.intervals = {
|
||||
year: 31536000,
|
||||
month: 2592000,
|
||||
week: 604800,
|
||||
day: 86400,
|
||||
hour: 3600,
|
||||
min: 60,
|
||||
sec: 1
|
||||
};
|
||||
} else {
|
||||
this.intervals = {
|
||||
year: 31536000,
|
||||
month: 2592000,
|
||||
@@ -38,7 +27,6 @@ export class TimeSinceComponent implements OnInit, OnChanges, OnDestroy {
|
||||
minute: 60,
|
||||
second: 1
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
@@ -65,7 +53,7 @@ export class TimeSinceComponent implements OnInit, OnChanges, OnDestroy {
|
||||
calculate() {
|
||||
const seconds = Math.floor((+new Date() - +new Date(this.time * 1000)) / 1000);
|
||||
if (seconds < 60) {
|
||||
return '< 1 minute';
|
||||
return $localize`:@@time-since.just-now:Just now`;
|
||||
}
|
||||
let counter;
|
||||
for (const i in this.intervals) {
|
||||
@@ -73,9 +61,41 @@ export class TimeSinceComponent implements OnInit, OnChanges, OnDestroy {
|
||||
counter = Math.floor(seconds / this.intervals[i]);
|
||||
if (counter > 0) {
|
||||
if (counter === 1) {
|
||||
return counter + ' ' + i; // singular (1 day ago)
|
||||
switch (i) { // singular (1 day ago)
|
||||
case 'year': return $localize`:@@time-since.year.ago:${counter}:INTERPOLATION: year ago`; break;
|
||||
case 'month': return $localize`:@@time-since.month.ago:${counter}:INTERPOLATION: month ago`; break;
|
||||
case 'week': return $localize`:@@time-since.week.ago:${counter}:INTERPOLATION: week ago`; break;
|
||||
case 'day': return $localize`:@@time-since.day.ago:${counter}:INTERPOLATION: day ago`; break;
|
||||
case 'hour': return $localize`:@@time-since.hour.ago:${counter}:INTERPOLATION: hour ago`; break;
|
||||
case 'minute':
|
||||
if (document.body.clientWidth < 768) {
|
||||
return $localize`:@@time-since.min.ago:${counter}:INTERPOLATION: min ago`;
|
||||
}
|
||||
return $localize`:@@time-since.minute.ago:${counter}:INTERPOLATION: minute ago`;
|
||||
case 'second':
|
||||
if (document.body.clientWidth < 768) {
|
||||
return $localize`:@@time-since.sec.ago:${counter}:INTERPOLATION: sec ago`;
|
||||
}
|
||||
return $localize`:@@time-since.second.ago:${counter}:INTERPOLATION: second ago`;
|
||||
}
|
||||
} else {
|
||||
return counter + ' ' + i + 's'; // plural (2 days ago)
|
||||
switch (i) { // plural (2 days ago)
|
||||
case 'year': return $localize`:@@time-since.years.ago:${counter}:INTERPOLATION: years ago`; break;
|
||||
case 'month': return $localize`:@@time-since.months.ago:${counter}:INTERPOLATION: months ago`; break;
|
||||
case 'week': return $localize`:@@time-since.weeks.ago:${counter}:INTERPOLATION: weeks ago`; break;
|
||||
case 'day': return $localize`:@@time-since.days.ago:${counter}:INTERPOLATION: days ago`; break;
|
||||
case 'hour': return $localize`:@@time-since.hours.ago:${counter}:INTERPOLATION: hours ago`; break;
|
||||
case 'minute':
|
||||
if (document.body.clientWidth < 768) {
|
||||
return $localize`:@@time-since.mins.ago:${counter}:INTERPOLATION: mins ago`;
|
||||
}
|
||||
return $localize`:@@time-since.minutes.ago:${counter}:INTERPOLATION: minutes ago`;
|
||||
case 'second':
|
||||
if (document.body.clientWidth < 768) {
|
||||
return $localize`:@@time-since.secs.ago:${counter}:INTERPOLATION: secs ago`;
|
||||
}
|
||||
return $localize`:@@time-since.seconds.ago:${counter}:INTERPOLATION: seconds ago`;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user