Translate Frontend Utilities

Closes #4096

Co-Authored-By: Stevie Robinson <stevie.robinson@gmail.com>
pull/4572/head
Qstick 9 months ago
parent f13b095040
commit 8b85d4c941

@ -4,19 +4,19 @@ const monitorNewItemsOptions = [
{
key: 'all',
get value() {
return translate('AllAlbums');
return translate('MonitorAllAlbums');
}
},
{
key: 'none',
get value() {
return translate('None');
return translate('MonitorNoNewAlbums');
}
},
{
key: 'new',
get value() {
return translate('New');
return translate('MonitorNewAlbums');
}
}
];

@ -1,11 +1,48 @@
import translate from 'Utilities/String/translate';
const monitorOptions = [
{ key: 'all', value: 'All Albums' },
{ key: 'future', value: 'Future Albums' },
{ key: 'missing', value: 'Missing Albums' },
{ key: 'existing', value: 'Existing Albums' },
{ key: 'first', value: 'Only First Album' },
{ key: 'latest', value: 'Only Latest Album' },
{ key: 'none', value: 'None' }
{
key: 'all',
get value() {
return translate('MonitorAllAlbums');
}
},
{
key: 'future',
get value() {
return translate('MonitorFutureAlbums');
}
},
{
key: 'missing',
get value() {
return translate('MonitorMissingAlbums');
}
},
{
key: 'existing',
get value() {
return translate('MonitorExistingAlbums');
}
},
{
key: 'first',
get value() {
return translate('MonitorFirstAlbum');
}
},
{
key: 'latest',
get value() {
return translate('MonitorLastestAlbum');
}
},
{
key: 'none',
get value() {
return translate('MonitorNoAlbums');
}
}
];
export default monitorOptions;

@ -1,4 +1,5 @@
import moment from 'moment';
import translate from 'Utilities/String/translate';
import formatTime from './formatTime';
import isToday from './isToday';
import isTomorrow from './isTomorrow';
@ -10,15 +11,15 @@ function getRelativeDay(date, includeRelativeDate) {
}
if (isYesterday(date)) {
return 'Yesterday, ';
return translate('Yesterday');
}
if (isToday(date)) {
return 'Today, ';
return translate('Today');
}
if (isTomorrow(date)) {
return 'Tomorrow, ';
return translate('Tomorrow');
}
return '';
@ -33,7 +34,10 @@ function formatDateTime(date, dateFormat, timeFormat, { includeSeconds = false,
const formattedDate = moment(date).format(dateFormat);
const formattedTime = formatTime(date, timeFormat, { includeMinuteZero: true, includeSeconds });
return `${relativeDay}${formattedDate} ${formattedTime}`;
if (relativeDay) {
return translate('FormatDateTimeRelative', { relativeDay, formattedDate, formattedTime });
}
return translate('FormatDateTime', { formattedDate, formattedTime });
}
export default formatDateTime;

@ -1,4 +1,5 @@
import moment from 'moment';
import translate from 'Utilities/String/translate';
function formatShortTimeSpan(timeSpan) {
if (!timeSpan) {
@ -12,14 +13,14 @@ function formatShortTimeSpan(timeSpan) {
const seconds = Math.floor(duration.asSeconds());
if (hours > 0) {
return `${hours} hour(s)`;
return translate('FormatShortTimeSpanHours', { hours });
}
if (minutes > 0) {
return `${minutes} minute(s)`;
return translate('FormatShortTimeSpanMinutes', { minutes });
}
return `${seconds} second(s)`;
return translate('FormatShortTimeSpanSeconds', { seconds });
}
export default formatShortTimeSpan;

@ -1,5 +1,6 @@
import moment from 'moment';
import padNumber from 'Utilities/Number/padNumber';
import translate from 'Utilities/String/translate';
function formatTimeSpan(timeSpan) {
if (!timeSpan) {
@ -16,7 +17,7 @@ function formatTimeSpan(timeSpan) {
const time = `${hours}:${minutes}:${seconds}`;
if (days > 0) {
return `${days}d ${time}`;
return translate('FormatTimeSpanDays', { days, time });
}
return time;

@ -4,6 +4,7 @@ import isInNextWeek from 'Utilities/Date/isInNextWeek';
import isToday from 'Utilities/Date/isToday';
import isTomorrow from 'Utilities/Date/isTomorrow';
import isYesterday from 'Utilities/Date/isYesterday';
import translate from 'Utilities/String/translate';
function getRelativeDate(date, shortDateFormat, showRelativeDates, { timeFormat, includeSeconds = false, timeForToday = false } = {}) {
if (!date) {
@ -21,15 +22,15 @@ function getRelativeDate(date, shortDateFormat, showRelativeDates, { timeFormat,
}
if (isYesterday(date)) {
return 'Yesterday';
return translate('Yesterday');
}
if (isTodayDate) {
return 'Today';
return translate('Today');
}
if (isTomorrow(date)) {
return 'Tomorrow';
return translate('Tomorrow');
}
if (isInNextWeek(date)) {

@ -1,3 +1,5 @@
import translate from 'Utilities/String/translate';
function formatAge(age, ageHours, ageMinutes) {
age = Math.round(age);
ageHours = parseFloat(ageHours);
@ -5,13 +7,13 @@ function formatAge(age, ageHours, ageMinutes) {
if (age < 2 && ageHours) {
if (ageHours < 2 && !!ageMinutes) {
return `${ageMinutes.toFixed(0)} ${ageHours === 1 ? 'minute' : 'minutes'}`;
return `${ageMinutes.toFixed(0)} ${ageHours === 1 ? translate('FormatAgeMinute') : translate('FormatAgeMinutes')}`;
}
return `${ageHours.toFixed(1)} ${ageHours === 1 ? 'hour' : 'hours'}`;
return `${ageHours.toFixed(1)} ${ageHours === 1 ? translate('FormatAgeHour') : translate('FormatAgeHours')}`;
}
return `${age} ${age === 1 ? 'day' : 'days'}`;
return `${age} ${age === 1 ? translate('FormatAgeDay') : translate('FormatAgeDays')}`;
}
export default formatAge;

@ -476,6 +476,20 @@
"ForNewImportsOnly": "For new imports only",
"ForeignId": "Foreign Id",
"ForeignIdHelpText": "The Musicbrainz Id of the artist/album to exclude",
"FormatAgeDay": "day",
"FormatAgeDays": "days",
"FormatAgeHour": "hour",
"FormatAgeHours": "hours",
"FormatAgeMinute": "minute",
"FormatAgeMinutes": "minutes",
"FormatDateTimeRelative": "{relativeDay}, {formattedDate} {formattedTime}",
"FormatDateTime": "{formattedDate} {formattedTime}",
"FormatRuntimeHours": "{hours}h",
"FormatRuntimeMinutes": "{minutes}m",
"FormatShortTimeSpanHours": "{hours} hour(s)",
"FormatShortTimeSpanMinutes": "{minutes} minute(s)",
"FormatShortTimeSpanSeconds": "{seconds} second(s)",
"FormatTimeSpanDays": "{days}d {time}",
"Formats": "Formats",
"FreeSpace": "Free Space",
"FutureAlbums": "Future Albums",
@ -680,12 +694,19 @@
"Monitor": "Monitor",
"MonitorAlbum": "Monitor Album",
"MonitorAlbumExistingOnlyWarning": "This is a one off adjustment of the monitored setting for each album. Use the option under Artist/Edit to control what happens for newly added albums",
"MonitorAllAlbums": "All Albums",
"MonitorArtist": "Monitor Artist",
"MonitorArtists": "Monitor Artists",
"MonitorExistingAlbums": "Monitor Existing Albums",
"MonitorNewAlbums": "Monitor New Albums",
"MonitorExistingAlbums": "Existing Albums",
"MonitorFirstAlbum": "First Album",
"MonitorFutureAlbums": "Future Albums",
"MonitorLastestAlbum": "Lastest Album",
"MonitorMissingAlbums": "Missing Albums",
"MonitorNewAlbums": "New Albums",
"MonitorNewItems": "Monitor New Albums",
"MonitorNewItemsHelpText": "Which new albums should be monitored",
"MonitorNoAlbums": "None",
"MonitorNoNewAlbums": "No New Albums",
"Monitored": "Monitored",
"MonitoredHelpText": "Download monitored albums from this artist",
"MonitoredOnly": "Monitored Only",
@ -1099,6 +1120,7 @@
"TimeFormat": "Time Format",
"TimeLeft": "Time Left",
"Title": "Title",
"Tomorrow": "Tomorrow",
"TorrentDelay": "Torrent Delay",
"TorrentDelayHelpText": "Delay in minutes to wait before grabbing a torrent",
"Torrents": "Torrents",
@ -1220,5 +1242,6 @@
"WriteMetadataToAudioFiles": "Write Metadata to Audio Files",
"Year": "Year",
"Yes": "Yes",
"YesCancel": "Yes, Cancel"
"YesCancel": "Yes, Cancel",
"Yesterday": "Yesterday"
}

Loading…
Cancel
Save