Use helpers to check environment in frontend (#27633)
This commit is contained in:
parent
7ef56d6e50
commit
277e6968f5
8 changed files with 28 additions and 9 deletions
|
|
@ -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: {} };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue