[Glitch] Fix /share and cleanup and reorganize frontend locale loading

Port b0780cfeed to glitch-soc

Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
Renaud Chaput
2023-06-02 15:00:27 +02:00
committed by Claire
parent 734e186717
commit 9e66c07be7
14 changed files with 151 additions and 86 deletions

View File

@@ -6,14 +6,14 @@ import ready from 'flavours/glitch/ready';
ready(() => {
[].forEach.call(document.querySelectorAll('[data-admin-component]'), element => {
const componentName = element.getAttribute('data-admin-component');
const { locale, ...componentProps } = JSON.parse(element.getAttribute('data-props'));
const { ...componentProps } = JSON.parse(element.getAttribute('data-props'));
import('flavours/glitch/containers/admin_component').then(({ default: AdminComponent }) => {
return import('flavours/glitch/components/admin/' + componentName).then(({ default: Component }) => {
const root = createRoot(element);
root.render (
<AdminComponent locale={locale}>
<AdminComponent>
<Component {...componentProps} />
</AdminComponent>,
);

View File

@@ -1,11 +1,11 @@
import 'packs/public-path';
import { loadLocale } from 'flavours/glitch/load_locale';
import { loadLocale } from 'flavours/glitch/locales';
import main from "flavours/glitch/main";
import { loadPolyfills } from 'flavours/glitch/polyfills';
loadPolyfills().then(loadLocale).then(async () => {
const { default: main } = await import('flavours/glitch/main');
return main();
}).catch(e => {
console.error(e);
});
loadPolyfills()
.then(loadLocale)
.then(main)
.catch(e => {
console.error(e);
});

View File

@@ -1,7 +1,7 @@
import 'packs/public-path';
import { createRoot } from 'react-dom/client';
import * as IntlMessageFormat from 'intl-messageformat';
import { IntlMessageFormat } from 'intl-messageformat';
import { defineMessages } from 'react-intl';
import { delegate } from '@rails/ujs';
@@ -12,10 +12,9 @@ import { throttle } from 'lodash';
import { timeAgoString } from 'flavours/glitch/components/relative_timestamp';
import emojify from 'flavours/glitch/features/emoji/emoji';
import loadKeyboardExtensions from 'flavours/glitch/load_keyboard_extensions';
import { loadLocale } from 'flavours/glitch/load_locale';
import { loadLocale, getLocale } from 'flavours/glitch/locales';
import { loadPolyfills } from 'flavours/glitch/polyfills';
import ready from 'flavours/glitch/ready';
import { getLocale } from 'locales';
const messages = defineMessages({
usernameTaken: { id: 'username.taken', defaultMessage: 'That username is taken. Try another' },
@@ -24,7 +23,7 @@ const messages = defineMessages({
});
function main() {
const { localeData } = getLocale();
const { messages: localeData } = getLocale();
const scrollToDetailedStatus = () => {
const history = createBrowserHistory();

View File

@@ -2,7 +2,6 @@ import 'packs/public-path';
import { createRoot } from 'react-dom/client';
import ComposeContainer from 'flavours/glitch/containers/compose_container';
import { loadLocale } from 'flavours/glitch/load_locale';
import { loadPolyfills } from 'flavours/glitch/polyfills';
import ready from 'flavours/glitch/ready';
@@ -23,6 +22,6 @@ function main() {
ready(loaded);
}
loadPolyfills().then(loadLocale).then(main).catch(error => {
loadPolyfills().then(main).catch(error => {
console.error(error);
});