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', key: 'all',
get value() { get value() {
return translate('AllAlbums'); return translate('MonitorAllAlbums');
} }
}, },
{ {
key: 'none', key: 'none',
get value() { get value() {
return translate('None'); return translate('MonitorNoNewAlbums');
} }
}, },
{ {
key: 'new', key: 'new',
get value() { get value() {
return translate('New'); return translate('MonitorNewAlbums');
} }
} }
]; ];

@ -1,11 +1,48 @@
import translate from 'Utilities/String/translate';
const monitorOptions = [ const monitorOptions = [
{ key: 'all', value: 'All Albums' }, {
{ key: 'future', value: 'Future Albums' }, key: 'all',
{ key: 'missing', value: 'Missing Albums' }, get value() {
{ key: 'existing', value: 'Existing Albums' }, return translate('MonitorAllAlbums');
{ key: 'first', value: 'Only First Album' }, }
{ key: 'latest', value: 'Only Latest Album' }, },
{ key: 'none', value: 'None' } {
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; export default monitorOptions;

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

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

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

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

@ -1,3 +1,5 @@
import translate from 'Utilities/String/translate';
function formatAge(age, ageHours, ageMinutes) { function formatAge(age, ageHours, ageMinutes) {
age = Math.round(age); age = Math.round(age);
ageHours = parseFloat(ageHours); ageHours = parseFloat(ageHours);
@ -5,13 +7,13 @@ function formatAge(age, ageHours, ageMinutes) {
if (age < 2 && ageHours) { if (age < 2 && ageHours) {
if (ageHours < 2 && !!ageMinutes) { 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; export default formatAge;

@ -476,6 +476,20 @@
"ForNewImportsOnly": "For new imports only", "ForNewImportsOnly": "For new imports only",
"ForeignId": "Foreign Id", "ForeignId": "Foreign Id",
"ForeignIdHelpText": "The Musicbrainz Id of the artist/album to exclude", "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", "Formats": "Formats",
"FreeSpace": "Free Space", "FreeSpace": "Free Space",
"FutureAlbums": "Future Albums", "FutureAlbums": "Future Albums",
@ -680,12 +694,19 @@
"Monitor": "Monitor", "Monitor": "Monitor",
"MonitorAlbum": "Monitor Album", "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", "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", "MonitorArtist": "Monitor Artist",
"MonitorArtists": "Monitor Artists", "MonitorArtists": "Monitor Artists",
"MonitorExistingAlbums": "Monitor Existing Albums", "MonitorExistingAlbums": "Existing Albums",
"MonitorNewAlbums": "Monitor New Albums", "MonitorFirstAlbum": "First Album",
"MonitorFutureAlbums": "Future Albums",
"MonitorLastestAlbum": "Lastest Album",
"MonitorMissingAlbums": "Missing Albums",
"MonitorNewAlbums": "New Albums",
"MonitorNewItems": "Monitor New Albums", "MonitorNewItems": "Monitor New Albums",
"MonitorNewItemsHelpText": "Which new albums should be monitored", "MonitorNewItemsHelpText": "Which new albums should be monitored",
"MonitorNoAlbums": "None",
"MonitorNoNewAlbums": "No New Albums",
"Monitored": "Monitored", "Monitored": "Monitored",
"MonitoredHelpText": "Download monitored albums from this artist", "MonitoredHelpText": "Download monitored albums from this artist",
"MonitoredOnly": "Monitored Only", "MonitoredOnly": "Monitored Only",
@ -1099,6 +1120,7 @@
"TimeFormat": "Time Format", "TimeFormat": "Time Format",
"TimeLeft": "Time Left", "TimeLeft": "Time Left",
"Title": "Title", "Title": "Title",
"Tomorrow": "Tomorrow",
"TorrentDelay": "Torrent Delay", "TorrentDelay": "Torrent Delay",
"TorrentDelayHelpText": "Delay in minutes to wait before grabbing a torrent", "TorrentDelayHelpText": "Delay in minutes to wait before grabbing a torrent",
"Torrents": "Torrents", "Torrents": "Torrents",
@ -1220,5 +1242,6 @@
"WriteMetadataToAudioFiles": "Write Metadata to Audio Files", "WriteMetadataToAudioFiles": "Write Metadata to Audio Files",
"Year": "Year", "Year": "Year",
"Yes": "Yes", "Yes": "Yes",
"YesCancel": "Yes, Cancel" "YesCancel": "Yes, Cancel",
"Yesterday": "Yesterday"
} }

Loading…
Cancel
Save