-
Notifications
You must be signed in to change notification settings - Fork 37
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
[VO-1035 & VO-1034 & VO-1036] fix(AppSections): Some fixes linked to additional apps on cozy-store #2697
Merged
Merged
[VO-1035 & VO-1034 & VO-1036] fix(AppSections): Some fixes linked to additional apps on cozy-store #2697
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
72b345a
feat(AppSections): Rename shortcuts section to additional apps
cballevre d7220d9
refactor(AppSections): Use withOnlyLocales instead of withLocales
cballevre bf8fca8
refactor(I18n): Extract useExtendI18n into its own file
cballevre d4c79fb
refactor(AppSections): Use hook instead of withBreakpoints hoc
cballevre 6609f39
fix(I18n): Allow multiple locales extensions in apps by isolating state
cballevre 96803de
fix(AppTile): Show favorite label also desktop
cballevre 9d87df2
fix(AppTile): Display the name of the developer instead custom property
cballevre File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import Polyglot from 'node-polyglot' | ||
import { useState } from 'react' | ||
|
||
import { useI18n } from '.' | ||
import { extend } from './translation' | ||
|
||
/** | ||
* Hook to merge app locales with cozy-ui locales | ||
* @param {object} locales - Locales sorted by lang `{ fr: {...}, en: {...} }` | ||
* @returns {void} | ||
*/ | ||
const useExtendI18n = locales => { | ||
const { lang, polyglot } = useI18n() | ||
// Use to determine if we need to merge locales again, and to avoid useless calls | ||
const [useExtendI18nLang, setUseExtendI18nLang] = useState('') | ||
|
||
if (!locales || !lang || !polyglot) return | ||
|
||
// To simplify code we use Polyglot.extend to merge | ||
// locales from object and from polyglot.phrases | ||
// rather than native JS or lodash. this is why we have two extend. | ||
if (useExtendI18nLang !== lang) { | ||
const _polyglot = new Polyglot({ | ||
phrases: locales[lang], | ||
locale: lang | ||
}) | ||
|
||
// merge locales from app and cozy-ui, without replacing existing one in app | ||
extend(polyglot.phrases, _polyglot) | ||
// use merged locales in app | ||
extend(_polyglot.phrases, polyglot) | ||
// set the switch to avoid useless merge | ||
setUseExtendI18nLang(lang) | ||
} | ||
} | ||
|
||
export default useExtendI18n |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bien vu 👍 il faudrait peut-être corriger le titre du commit "more than once quoi ?" et ajouter un commentaire sur le commit pour expliquer le correctif
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
J'ai rajouté un commentaire pour être plus explicite