Skip to content

Refactor translation system#5753

Merged
vesameskanen merged 33 commits intov3from
split-translations
Apr 20, 2026
Merged

Refactor translation system#5753
vesameskanen merged 33 commits intov3from
split-translations

Conversation

@vesameskanen
Copy link
Copy Markdown
Member

  • Get rid of complicated and unnecessary StoreListeningIntlProvider.js
  • Split translations to one file per language
  • Load only one single language bundle for the current language
  • Refactor message bar related utils to use new single language localization
  • Remove about 200 unused translations per language
  • Remove outdated complicated polyfill code
  • Remove some unused styles
  • Update unit tests

Copy link
Copy Markdown
Contributor

@VillePihlava VillePihlava left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Can you rename the intl folder to translations? Makes a bit more clearer. If theres a good reason to name it intl then its fine.
  • I did not look at individual translations files.
  • We should update to react-intl version 3. It should be compatible with react version 16. This probably removes a lot of code. I will rereview once this has been done.

Comment thread test/unit/translations.test.js Outdated
Comment thread server/passport-openid-connect/openidConnect.js
Comment thread app/util/geolocationMessages.js Outdated
Comment thread app/util/geolocationMessages.js Outdated
content: translations[key],
});
});
geolocationMessages[e] = message;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like the mutable state here. How much work would it take to just use the return value from this function?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case the function should be renamed to getGeolocationMessages

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These messages are a global resource which is not used from react components. Messages are built here once.

We could, of course, pass translations and current language to this file and build each message dynamically when needed with a 'getMessage' func, but we still niin the init call to store language and translations for later use.

Comment thread app/util/messageUtils.js Outdated
Comment on lines +32 to +41
messages[key] = {
id: key,
persistence: 'repeat',
priority: 4,
icon: 'caution_white_exclamation',
iconColor: '#dc0451',
backgroundColor: '#fdf0f5',
type: 'error',
content,
};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, mutable state vs return value.

Comment thread app/util/messageUtils.js Outdated
Comment on lines +53 to +58
export function failedFavouriteMessage(type, isSave) {
const t = favouriteTypes.includes(type) ? type : favouriteTypes[0];
const key = isSave
? `add-favourite-${t}-failed-heading`
: 'delete-favourite-failed-heading';
return messages[key];
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the messages are e.g. put in the global context, then this could be a util function that takes the current set of messages as a parameter

@vesameskanen vesameskanen merged commit 1e6ed97 into v3 Apr 20, 2026
7 checks passed
@vesameskanen vesameskanen deleted the split-translations branch April 20, 2026 16:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants