Translate Frontend Utilities

pull/5994/head
Stevie Robinson 1 year ago committed by GitHub
parent faecdc855f
commit 3f0e8ce863
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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;

@ -1,3 +1,5 @@
import translate from 'Utilities/String/translate';
function formatRuntime(runtime: number) {
if (!runtime) {
return '';
@ -8,11 +10,11 @@ function formatRuntime(runtime: number) {
const result = [];
if (hours) {
result.push(`${hours}h`);
result.push(translate('FormatRuntimeHours', { hours }));
}
if (minutes) {
result.push(`${minutes}m`);
result.push(translate('FormatRuntimeMinutes', { minutes }));
}
return result.join(' ');

@ -1,14 +1,66 @@
import translate from 'Utilities/String/translate';
const monitorOptions = [
{ key: 'all', value: 'All Episodes' },
{ key: 'future', value: 'Future Episodes' },
{ key: 'missing', value: 'Missing Episodes' },
{ key: 'existing', value: 'Existing Episodes' },
{ key: 'pilot', value: 'Pilot Episode' },
{ key: 'firstSeason', value: 'Only First Season' },
{ key: 'latestSeason', value: 'Only Latest Season' },
{ key: 'monitorSpecials', value: 'Monitor Specials' },
{ key: 'unmonitorSpecials', value: 'Unmonitor Specials' },
{ key: 'none', value: 'None' }
{
key: 'all',
get value() {
return translate('MonitorAllEpisodes');
}
},
{
key: 'future',
get value() {
return translate('MonitorFutureEpisodes');
}
},
{
key: 'missing',
get value() {
return translate('MonitorMissingEpisodes');
}
},
{
key: 'existing',
get value() {
return translate('MonitorExistingEpisodes');
}
},
{
key: 'pilot',
get value() {
return translate('MonitorPilotEpisode');
}
},
{
key: 'firstSeason',
get value() {
return translate('MonitorFirstSeason');
}
},
{
key: 'latestSeason',
get value() {
return translate('MonitorLatestSeason');
}
},
{
key: 'monitorSpecials',
get value() {
return translate('MonitorSpecials');
}
},
{
key: 'unmonitorSpecials',
get value() {
return translate('UnmonitorSpecials');
}
},
{
key: 'none',
get value() {
return translate('MonitorNone');
}
}
];
export default monitorOptions;

@ -525,6 +525,20 @@
"Folder": "Folder",
"Folders": "Folders",
"Forecast": "Forecast",
"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",
"Forums": "Forums",
"FreeSpace": "Free Space",
@ -784,6 +798,7 @@
"MonitorMissingEpisodesDescription": "Monitor episodes that do not have files or have not aired yet",
"MonitorNone": "None",
"MonitorNoneDescription": "No episodes will be monitored",
"MonitorPilotEpisode": "Pilot Episode",
"MonitorSelected": "Monitor Selected",
"MonitorSeries": "Monitor Series",
"MonitorSpecials": "Monitor Specials",
@ -1357,6 +1372,7 @@
"ToggleMonitoredSeriesUnmonitored ": "Cannot toggle monitored state when series is unmonitored",
"ToggleMonitoredToUnmonitored": "Monitored, click to unmonitor",
"ToggleUnmonitoredToMonitored": "Unmonitored, click to monitor",
"Tomorrow": "Tomorrow",
"TorrentDelay": "Torrent Delay",
"TorrentDelayHelpText": "Delay in minutes to wait before grabbing a torrent",
"TorrentDelayTime": "Torrent Delay: {torrentDelay}",
@ -1466,5 +1482,6 @@
"WouldYouLikeToRestoreBackup": "Would you like to restore the backup '{name}'?",
"Year": "Year",
"Yes": "Yes",
"YesCancel": "Yes, Cancel"
"YesCancel": "Yes, Cancel",
"Yesterday": "Yesterday"
}

Loading…
Cancel
Save