Fix /share
and cleanup and reorganize frontend locale loading (#25240)
This commit is contained in:
parent
5fae2de454
commit
b0780cfeed
25 changed files with 152 additions and 638 deletions
22
app/javascript/mastodon/locales/global_locale.ts
Normal file
22
app/javascript/mastodon/locales/global_locale.ts
Normal file
|
@ -0,0 +1,22 @@
|
|||
export interface LocaleData {
|
||||
locale: string;
|
||||
messages: Record<string, string>;
|
||||
}
|
||||
|
||||
let loadedLocale: LocaleData;
|
||||
|
||||
export function setLocale(locale: LocaleData) {
|
||||
loadedLocale = locale;
|
||||
}
|
||||
|
||||
export function getLocale() {
|
||||
if (!loadedLocale && process.env.NODE_ENV === 'development') {
|
||||
throw new Error('getLocale() called before any locale has been set');
|
||||
}
|
||||
|
||||
return loadedLocale;
|
||||
}
|
||||
|
||||
export function isLocaleLoaded() {
|
||||
return !!loadedLocale;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue