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

Further improvements to migration guide for switching locales #1905

Closed
matthewmayer opened this issue Mar 7, 2023 · 5 comments · Fixed by #2125
Closed

Further improvements to migration guide for switching locales #1905

matthewmayer opened this issue Mar 7, 2023 · 5 comments · Fixed by #2125
Assignees
Labels
c: docs Improvements or additions to documentation

Comments

@matthewmayer
Copy link
Contributor

matthewmayer commented Mar 7, 2023

Followon from #1735

This "old" example in the migration guide on https://next.fakerjs.dev/guide/upgrading.html has problems

  • The Old code doesn't compile on v7 - Faker, de_CH, de and en are not defined.
  • I'm not sure what the correct syntax for a custom Faker instance was on v7.x?

Old:

import { faker } from '@faker-js/faker';

const customFaker = new Faker({
  locale: 'de_CH', // the expected locale
  fallbackLocale: 'de', // ensure we have a German fallbacks for addresses
  locales: { de_CH, de, en },
});
const a = customFaker.internet.email();
customFaker.locale = 'en'; // neither 'de_CH' nor 'de' have emojis
const b = customFaker.internet.emoji();
@Shinigami92 Shinigami92 added the c: docs Improvements or additions to documentation label Mar 8, 2023
@Shinigami92 Shinigami92 added this to the v8.0 - Module Re-Shuffling milestone Mar 8, 2023
@Shinigami92 Shinigami92 moved this to Todo in Faker Roadmap Mar 8, 2023
@matthewmayer
Copy link
Contributor Author

Tried to tweak the old example to compile, but not sure what the correct syntax is for Faker v7.x?

@ST-DDT
Copy link
Member

ST-DDT commented Apr 16, 2023

The old imports only work for CJS.

@matthewmayer
Copy link
Contributor Author

I also get an error using CJS on faker 7

@ST-DDT
Copy link
Member

ST-DDT commented Apr 17, 2023

Please post the error message or explain what isn't working.

@matthewmayer
Copy link
Contributor Author

ok i think i got it. Faker 7.x.x used "localeFallback" but the docs say "fallbackLocale"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: docs Improvements or additions to documentation
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants