Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/rare-fans-shake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket.chat/meteor': patch
---

Fixes some locale loading issues for date-time formatting functionality.
16 changes: 12 additions & 4 deletions apps/meteor/server/lib/getMomentLocale.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
import { Meteor } from 'meteor/meteor';

const mapLocaleToMomentLocale: Record<string, string> = {
ug: 'ug-cn',
zh: 'zh-cn',
};

export async function getMomentLocale(locale: string): Promise<string | undefined> {
Comment thread
yash-rajpal marked this conversation as resolved.
const localeLower = locale.toLowerCase();

try {
return Assets.getTextAsync(`moment-locales/${localeLower}.js`);
return await Assets.getTextAsync(`moment-locales/${localeLower}.js`);
} catch (error) {
try {
return Assets.getTextAsync(`moment-locales/${String(localeLower.split('-').shift())}.js`);
return await Assets.getTextAsync(`moment-locales/${String(localeLower.split('-').shift())}.js`);
} catch (error) {
throw new Meteor.Error('moment-locale-not-found', `Moment locale not found: ${locale}`);
try {
return await Assets.getTextAsync(`moment-locales/${mapLocaleToMomentLocale[localeLower]}.js`);
} catch (error) {
throw new Meteor.Error('moment-locale-not-found', `Moment locale not found: ${locale}`);
}
}
}
}
Loading