File size: 921 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import { getLocaleSlug } from 'i18n-calypso';
import { get } from 'lodash';
import moment from 'moment';

export function getMaintenanceMessageFromError( error, translate ) {
	const maintenanceEndTime = get( error, [ 'data', 'maintenance_end_time' ], null );
	const localeSlug = getLocaleSlug();

	if ( maintenanceEndTime ) {
		return translate(
			"Our domain management system is currently undergoing maintenance and we can't process your request right now. Please try again %(when)s.",
			{
				args: {
					when: moment.unix( maintenanceEndTime ).locale( localeSlug ).fromNow(),
				},
				comment:
					'Where `when` is human readable time interval generated from moment.fromNow - something like "in an hour" or "in 30 minutes" and etc.',
			}
		);
	}

	return translate(
		"Our domain management system is currently undergoing maintenance and we can't process your request right now. Please try again later."
	);
}