Comment improvements - #2460
Merged
Merged
Conversation
So far the frontend I18n.locale has been set to the entry locale both for published entries and previews. Since only the entry itself was rendered, there was no user interface that would have needed the locale of the signed in user. With commenting, preview mode renders review interface on top of the entry. Pass the locale of the signed in user via the request env and use it for the locale and the review/inline_editing translations of the seed. Frontend code obtains the entry locale from the entry metadata, which the seed continues to render based on the entry. Keep setting I18n.locale to the entry locale while rendering, though: Templates and widgets rely on it to render the entry itself, e.g. for the dc.language meta tag, the privacy notice label and file licenses. Published entries keep rendering the entry locale in the seed since their markup is cached without taking the requesting user into account.
useI18n has been able to translate in the locale of the user interface rather than the entry locale via the `locale: 'ui'` option. Components that format data instead of translating it had to read I18n.locale directly to achieve the same. Move the option to useLocale and let useI18n pass its options on. This way useI18n no longer needs to know how to obtain either locale.
Timestamps have been formatted according to English conventions no matter which locale the review interface was displayed in. Include the year for comments from previous years to keep them distinguishable from recent ones.
The review interface is bundled separately, so relative imports from src/frontend inlined a second copy of those modules into review.js. Since LocaleProvider is mounted from the frontend bundle, useLocale called through the inlined copy would have read its own LocaleContext and returned the default locale instead of the entry locale. Extend the eslint rule that already guards content elements, widgets and the editor to cover the review interface, and let it catch bare '../entryState' imports as well. Keep the spinner icon in the images directory of the review interface like its other icons.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
REDMINE-21261