New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix /share
and cleanup and reorganize frontend locale loading
#25240
Conversation
Note: I can also rework this to not move the locale JSON files and have the TS code in another directory if you prefer ( |
I understand the reason for moving the JSON files and I agree with it, but I'm not sure how well Crowdin handles that, so I'd like that to be postponed until we make sure this won't break anything with Crowdin. |
I can leave the JSON in
|
Do the TS files need to be kept out of that folder as a first step? If not, I'd postpone that split to a later PR, if yes, I'm fine with |
- No need for the `locale` prop anymore for root React components, this is read from `<html lang>` - Converted locale-related files to Typescript - No more locale loading as a side-effect. Locale data is loaded when the component/code is called, not imported. This avoid the need to dynamically import this code once the locale data has been loaded
`index.ts` re-exports what can be consumed by the app and nothing else
I removed the JSON file renaming. All TS files are in |
/share
and cleanup and reorganize frontend locale loading
My react-intl upgrade PR broke the locale loading on
/share
. This was caused bygetLocale
being called when importing files, as it is called in the root scope of the file.This is a bad practice and can easily lead to those files being imported/loaded while the locale is not loaded yet. The current code needs to dynamically import the various React components after
loadLocale
has been called, which is error-prone.Now, locale data is loaded when the component/code is called, not imported. This avoid the need to dynamically import this code once the locale data has been loaded
While I was working on this, I made some additional changes that I did not wanted to do in my initial PR to not make it too complex:
locale
prop anymore for root React components, this is read from<html lang>
mastodon/locales/
, which only exports the needed functions & types