Skip to content
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

Add support for getLocales in Polyglot i18nProvider #8143

Merged
merged 6 commits into from Sep 8, 2022
Merged

Conversation

fzaninotto
Copy link
Member

Follows #7758

@fzaninotto fzaninotto added the RFR Ready For Review label Sep 6, 2022
@fzaninotto fzaninotto changed the title Add support for getLocales in i18nProvider Add support for getLocales in Polyglot i18nProvider Sep 6, 2022
Copy link
Contributor

@djhi djhi left a comment

Choose a reason for hiding this comment

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

👍

docs/TranslationSetup.md Outdated Show resolved Hide resolved
examples/simple/src/i18nProvider.tsx Outdated Show resolved Hide resolved
*/
export default (
getMessages: GetMessages,
initialLocale: string = 'en',
availableLocales: Locale[] = [{ locale: 'en', name: 'English' }],
polyglotOptions: any = {}
): I18nProvider => {
let locale = initialLocale;
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't we throw a warning if the initialLocal is not in the availableLocales? Maybe I'm nitpicking here

Copy link
Member Author

Choose a reason for hiding this comment

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

nice to have ;)

Copy link
Contributor

@WiXSL WiXSL left a comment

Choose a reason for hiding this comment

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

TranslationSetup.md - line 152:
The specified anchor using-specific-polyglot-features is in the README of polyglot package, not above in the document.

This solution is all-or-nothing: you can't silence only some missing translation warnings. An alternative solution consists of passing a default translation using the _ translation option, as explained in the Using Specific Polyglot Features section(#using-specific-polyglot-features) above.

fzaninotto and others added 2 commits September 8, 2022 10:00
Co-authored-by: Gildas Garcia <1122076+djhi@users.noreply.github.com>
@slax57 slax57 added this to the 4.4.0 milestone Sep 8, 2022
@slax57 slax57 merged commit 31317e7 into next Sep 8, 2022
@slax57 slax57 deleted the getlocales-polyglot branch September 8, 2022 12:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RFR Ready For Review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants