The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Rocket.Chat/server/lib/getMomentLocale.ts

16 lines
466 B

import { Meteor } from 'meteor/meteor';
export function getMomentLocale(locale: string): string | undefined {
const localeLower = locale.toLowerCase();
try {
return Assets.getText(`moment-locales/${ localeLower }.js`);
} catch (error) {
try {
return Assets.getText(`moment-locales/${ String(localeLower.split('-').shift()) }.js`);
} catch (error) {
throw new Meteor.Error('moment-locale-not-found', `Moment locale not found: ${ locale }`);
}
}
}