Use helpers to check environment in frontend (#27633)

This commit is contained in:
Renaud Chaput 2023-10-31 17:05:44 +01:00 committed by GitHub
commit 277e6968f5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 28 additions and 9 deletions

View file

@ -1,3 +1,5 @@
import { isDevelopment } from 'mastodon/utils/environment';
export interface LocaleData {
locale: string;
messages: Record<string, string>;
@ -11,7 +13,7 @@ export function setLocale(locale: LocaleData) {
export function getLocale(): LocaleData {
if (!loadedLocale) {
if (process.env.NODE_ENV === 'development') {
if (isDevelopment()) {
throw new Error('getLocale() called before any locale has been set');
} else {
return { locale: 'unknown', messages: {} };