Skip to content

Conversation

@partisaani
Copy link
Contributor

Proposed Changes

  • Added missing translations
  • Added useTranslationContext hook to be used anywhere while preserving backwards compatibility
  • Filter related elements stick to the top of viewport when scrolling
  • General improvements and additions based on stakeholder feedback

Pull Request Check List

  • A reasonable set of unit tests is included
  • Console does not show new warnings/errors
  • Changes are documented or they are self explanatory
  • This pull request does not have any merge conflicts
  • All existing tests pass in CI build

Review

  • Read and verify the code changes
  • Test the functionality by running the UI locally with all popular browsers available in your platform
  • Check that the implementation matches the design, when such one is defined in an issue in Azure Boards
  • Merge the pull request

Comment on lines +16 to +19
const lang = document.cookie
.split(';')
.find(item => item.indexOf('lang=') > -1)
.split('=')[1];
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is there a better way to get a hold of the current language?

Copy link
Member

Choose a reason for hiding this comment

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

You should use app/store/PreferencesStore, where the current language is stored:

function component (props, context) {
const lang = context.getStore('PreferencesStore').getLanguage();
}

Actually the current way presented above is some sort of mistake. Stores are used for emitting changes which trigger component rendering. Lang does not change dynamically. UI server sends a cookie at first page load. If user changes the language, new page loading takes place. We could simply store the language to configuration.

Comment on lines +88 to +92
/* MAJOR_CHANGES: {
fi: 'TODO',
sv: 'TODO',
en: 'TODO',
}, */
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is currently unclear where this "suuret muutokset" link that was requested to be implemented should take the user

Comment on lines +16 to +18
export const useTranslationsContext = () => {
const intl = useContext(IntlContext);
if (!intl) {
Copy link
Member

Choose a reason for hiding this comment

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

I am not sure why you add new context providers? The old way of accesing config or intl from standard context looks so simple:


function mycomponent(props, context) {
   const intl = context.intl;
}


Copy link
Contributor

Choose a reason for hiding this comment

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

The old way of accessing context is deprecated in React versions newer than 16, so I think this is a welcoming change

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Futureproofing as @hjvuor said.

Accessing the context via a provider is also simpler in deeply nested components as there's no need to drill down the context prop.

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.

4 participants