-
-
Notifications
You must be signed in to change notification settings - Fork 973
docs: localization #1364
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
Merged
Merged
docs: localization #1364
Changes from 1 commit
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
a2a318c
docs: locales
Shinigami92 e767ec9
docs: locales
Shinigami92 08c056d
docs: locales
Shinigami92 e8c5d85
docs: merging old localization docs into new docs
Shinigami92 20703fb
docs: remove old link
Shinigami92 697d007
docs: merging old and new docs
Shinigami92 542150b
docs: improve wording
Shinigami92 8b11902
Update docs/guide/localization.md
Shinigami92 a1efce0
chore: rename constant
Shinigami92 422cc65
chore: fix links
Shinigami92 a548c8a
Update README.md
Shinigami92 1391356
Merge branch 'main' into docs-locales
Shinigami92 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 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Locales | ||
|
||
Did you know Faker supports many different locales? | ||
By default when using `import { faker } from '@faker-js/faker'` you actually use every available locale that is supported by Faker and you can switch the locale at runtime with `faker.setLocale('de')`. | ||
|
||
::: info | ||
Since [v7.3.0](https://github.com/faker-js/faker/releases/tag/v7.3.0) you can also just use `faker.locale = 'de'` instead to switch the locale. | ||
::: | ||
|
||
There is one downside of using the default faker instance because it will load all locales into memory resulting in a slower startup time. So if you encounter performance issues e.g. while running tests you should consider using customized faker instances. | ||
And we got you back! You can import specific pre-configured faker instances for each locale by just using e.g. `import { faker } from '@faker-js/faker/locale/de'`. | ||
Shinigami92 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
This will then just load the german locales with additional english locales as fallback. | ||
Shinigami92 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
:::info | ||
In v7 and earlier versions faker always use english as fallback. The english locales are around 600 KB in size. In v8 we plan to change the behavior and allow to create custom faker instances with e.g. only german but no english locales. | ||
Shinigami92 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
You will then safe these 600 KB of memory overhead but might run into issues when there is no value provided in the german locales. | ||
Shinigami92 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
::: |
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.
Uh oh!
There was an error while loading. Please reload this page.