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

feat: export locales #642

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,42 @@ See our documentation for a list of [provided languages](https://fakerjs.dev/api

### Individual Localization Packages

Faker supports incremental loading of locales.
Faker supports loading of individual locales.

```js
// loads only de locale
const { faker } = require('@faker-js/faker/locale/de');
```

Faker supports adding locale fallback.
cjs:

```cjs
const { Faker } = require('@faker-js/faker');
const { default: de } = require("@faker-js/faker/locale/de");
const { default: fr } = require("@faker-js/faker/locale/fr");

consta faker = new Faker({
locales: { de, fr },
locale: "de",
localeFallback: "fr",
});
```

esm:

```mjs
import { Faker } from '@faker-js/faker';
import de from "@faker-js/faker/locale/de";
import fr from "@faker-js/faker/locale/fr";

consta faker = new Faker({
locales: { de, fr },
locale: "de",
localeFallback: "fr",
});
```

## Setting a randomness seed

If you want consistent results, you can set your own seed:
Expand Down
2 changes: 2 additions & 0 deletions src/locale/af_ZA.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { Faker } from '../faker';
import af_ZA from '../locales/af_ZA';
import en from '../locales/en';

export { default } from '../locales/af_ZA';

export const faker = new Faker({
locale: 'af_ZA',
localeFallback: 'en',
Expand Down
2 changes: 2 additions & 0 deletions src/locale/ar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { Faker } from '../faker';
import ar from '../locales/ar';
import en from '../locales/en';

export { default } from '../locales/ar';

export const faker = new Faker({
locale: 'ar',
localeFallback: 'en',
Expand Down
2 changes: 2 additions & 0 deletions src/locale/az.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { Faker } from '../faker';
import az from '../locales/az';
import en from '../locales/en';

export { default } from '../locales/az';

export const faker = new Faker({
locale: 'az',
localeFallback: 'en',
Expand Down
2 changes: 2 additions & 0 deletions src/locale/cz.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { Faker } from '../faker';
import cz from '../locales/cz';
import en from '../locales/en';

export { default } from '../locales/cz';

export const faker = new Faker({
locale: 'cz',
localeFallback: 'en',
Expand Down
2 changes: 2 additions & 0 deletions src/locale/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { Faker } from '../faker';
import de from '../locales/de';
import en from '../locales/en';

export { default } from '../locales/de';

export const faker = new Faker({
locale: 'de',
localeFallback: 'en',
Expand Down
2 changes: 2 additions & 0 deletions src/locale/de_AT.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { Faker } from '../faker';
import de_AT from '../locales/de_AT';
import en from '../locales/en';

export { default } from '../locales/de_AT';

export const faker = new Faker({
locale: 'de_AT',
localeFallback: 'en',
Expand Down
2 changes: 2 additions & 0 deletions src/locale/de_CH.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { Faker } from '../faker';
import de_CH from '../locales/de_CH';
import en from '../locales/en';

export { default } from '../locales/de_CH';

export const faker = new Faker({
locale: 'de_CH',
localeFallback: 'en',
Expand Down
2 changes: 2 additions & 0 deletions src/locale/el.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { Faker } from '../faker';
import el from '../locales/el';
import en from '../locales/en';

export { default } from '../locales/el';

export const faker = new Faker({
locale: 'el',
localeFallback: 'en',
Expand Down
2 changes: 2 additions & 0 deletions src/locale/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import { Faker } from '../faker';
import en from '../locales/en';

export { default } from '../locales/en';

export const faker = new Faker({
locale: 'en',
localeFallback: 'en',
Expand Down
2 changes: 2 additions & 0 deletions src/locale/en_AU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { Faker } from '../faker';
import en from '../locales/en';
import en_AU from '../locales/en_AU';

export { default } from '../locales/en_AU';

export const faker = new Faker({
locale: 'en_AU',
localeFallback: 'en',
Expand Down
2 changes: 2 additions & 0 deletions src/locale/en_AU_ocker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { Faker } from '../faker';
import en from '../locales/en';
import en_AU_ocker from '../locales/en_AU_ocker';

export { default } from '../locales/en_AU_ocker';

export const faker = new Faker({
locale: 'en_AU_ocker',
localeFallback: 'en',
Expand Down
2 changes: 2 additions & 0 deletions src/locale/en_BORK.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { Faker } from '../faker';
import en from '../locales/en';
import en_BORK from '../locales/en_BORK';

export { default } from '../locales/en_BORK';

export const faker = new Faker({
locale: 'en_BORK',
localeFallback: 'en',
Expand Down
2 changes: 2 additions & 0 deletions src/locale/en_CA.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { Faker } from '../faker';
import en from '../locales/en';
import en_CA from '../locales/en_CA';

export { default } from '../locales/en_CA';

export const faker = new Faker({
locale: 'en_CA',
localeFallback: 'en',
Expand Down
2 changes: 2 additions & 0 deletions src/locale/en_GB.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { Faker } from '../faker';
import en from '../locales/en';
import en_GB from '../locales/en_GB';

export { default } from '../locales/en_GB';

export const faker = new Faker({
locale: 'en_GB',
localeFallback: 'en',
Expand Down
2 changes: 2 additions & 0 deletions src/locale/en_GH.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { Faker } from '../faker';
import en from '../locales/en';
import en_GH from '../locales/en_GH';

export { default } from '../locales/en_GH';

export const faker = new Faker({
locale: 'en_GH',
localeFallback: 'en',
Expand Down
2 changes: 2 additions & 0 deletions src/locale/en_IE.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { Faker } from '../faker';
import en from '../locales/en';
import en_IE from '../locales/en_IE';

export { default } from '../locales/en_IE';

export const faker = new Faker({
locale: 'en_IE',
localeFallback: 'en',
Expand Down
2 changes: 2 additions & 0 deletions src/locale/en_IND.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { Faker } from '../faker';
import en from '../locales/en';
import en_IND from '../locales/en_IND';

export { default } from '../locales/en_IND';

export const faker = new Faker({
locale: 'en_IND',
localeFallback: 'en',
Expand Down
2 changes: 2 additions & 0 deletions src/locale/en_NG.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { Faker } from '../faker';
import en from '../locales/en';
import en_NG from '../locales/en_NG';

export { default } from '../locales/en_NG';

export const faker = new Faker({
locale: 'en_NG',
localeFallback: 'en',
Expand Down
2 changes: 2 additions & 0 deletions src/locale/en_US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { Faker } from '../faker';
import en from '../locales/en';
import en_US from '../locales/en_US';

export { default } from '../locales/en_US';

export const faker = new Faker({
locale: 'en_US',
localeFallback: 'en',
Expand Down
2 changes: 2 additions & 0 deletions src/locale/en_ZA.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { Faker } from '../faker';
import en from '../locales/en';
import en_ZA from '../locales/en_ZA';

export { default } from '../locales/en_ZA';

export const faker = new Faker({
locale: 'en_ZA',
localeFallback: 'en',
Expand Down
2 changes: 2 additions & 0 deletions src/locale/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { Faker } from '../faker';
import en from '../locales/en';
import es from '../locales/es';

export { default } from '../locales/es';

export const faker = new Faker({
locale: 'es',
localeFallback: 'en',
Expand Down
2 changes: 2 additions & 0 deletions src/locale/es_MX.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { Faker } from '../faker';
import en from '../locales/en';
import es_MX from '../locales/es_MX';

export { default } from '../locales/es_MX';

export const faker = new Faker({
locale: 'es_MX',
localeFallback: 'en',
Expand Down
2 changes: 2 additions & 0 deletions src/locale/fa.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { Faker } from '../faker';
import en from '../locales/en';
import fa from '../locales/fa';

export { default } from '../locales/fa';

export const faker = new Faker({
locale: 'fa',
localeFallback: 'en',
Expand Down
2 changes: 2 additions & 0 deletions src/locale/fi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { Faker } from '../faker';
import en from '../locales/en';
import fi from '../locales/fi';

export { default } from '../locales/fi';

export const faker = new Faker({
locale: 'fi',
localeFallback: 'en',
Expand Down
2 changes: 2 additions & 0 deletions src/locale/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { Faker } from '../faker';
import en from '../locales/en';
import fr from '../locales/fr';

export { default } from '../locales/fr';

export const faker = new Faker({
locale: 'fr',
localeFallback: 'en',
Expand Down
2 changes: 2 additions & 0 deletions src/locale/fr_BE.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { Faker } from '../faker';
import en from '../locales/en';
import fr_BE from '../locales/fr_BE';

export { default } from '../locales/fr_BE';

export const faker = new Faker({
locale: 'fr_BE',
localeFallback: 'en',
Expand Down
2 changes: 2 additions & 0 deletions src/locale/fr_CA.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { Faker } from '../faker';
import en from '../locales/en';
import fr_CA from '../locales/fr_CA';

export { default } from '../locales/fr_CA';

export const faker = new Faker({
locale: 'fr_CA',
localeFallback: 'en',
Expand Down
2 changes: 2 additions & 0 deletions src/locale/fr_CH.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { Faker } from '../faker';
import en from '../locales/en';
import fr_CH from '../locales/fr_CH';

export { default } from '../locales/fr_CH';

export const faker = new Faker({
locale: 'fr_CH',
localeFallback: 'en',
Expand Down
2 changes: 2 additions & 0 deletions src/locale/ge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { Faker } from '../faker';
import en from '../locales/en';
import ge from '../locales/ge';

export { default } from '../locales/ge';

export const faker = new Faker({
locale: 'ge',
localeFallback: 'en',
Expand Down
2 changes: 2 additions & 0 deletions src/locale/he.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { Faker } from '../faker';
import en from '../locales/en';
import he from '../locales/he';

export { default } from '../locales/he';

export const faker = new Faker({
locale: 'he',
localeFallback: 'en',
Expand Down
2 changes: 2 additions & 0 deletions src/locale/hr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { Faker } from '../faker';
import en from '../locales/en';
import hr from '../locales/hr';

export { default } from '../locales/hr';

export const faker = new Faker({
locale: 'hr',
localeFallback: 'en',
Expand Down
2 changes: 2 additions & 0 deletions src/locale/hu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { Faker } from '../faker';
import en from '../locales/en';
import hu from '../locales/hu';

export { default } from '../locales/hu';

export const faker = new Faker({
locale: 'hu',
localeFallback: 'en',
Expand Down
2 changes: 2 additions & 0 deletions src/locale/hy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { Faker } from '../faker';
import en from '../locales/en';
import hy from '../locales/hy';

export { default } from '../locales/hy';

export const faker = new Faker({
locale: 'hy',
localeFallback: 'en',
Expand Down
2 changes: 2 additions & 0 deletions src/locale/id_ID.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { Faker } from '../faker';
import en from '../locales/en';
import id_ID from '../locales/id_ID';

export { default } from '../locales/id_ID';

export const faker = new Faker({
locale: 'id_ID',
localeFallback: 'en',
Expand Down
2 changes: 2 additions & 0 deletions src/locale/it.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { Faker } from '../faker';
import en from '../locales/en';
import it from '../locales/it';

export { default } from '../locales/it';

export const faker = new Faker({
locale: 'it',
localeFallback: 'en',
Expand Down
2 changes: 2 additions & 0 deletions src/locale/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { Faker } from '../faker';
import en from '../locales/en';
import ja from '../locales/ja';

export { default } from '../locales/ja';

export const faker = new Faker({
locale: 'ja',
localeFallback: 'en',
Expand Down
2 changes: 2 additions & 0 deletions src/locale/ko.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { Faker } from '../faker';
import en from '../locales/en';
import ko from '../locales/ko';

export { default } from '../locales/ko';

export const faker = new Faker({
locale: 'ko',
localeFallback: 'en',
Expand Down
2 changes: 2 additions & 0 deletions src/locale/lv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { Faker } from '../faker';
import en from '../locales/en';
import lv from '../locales/lv';

export { default } from '../locales/lv';

export const faker = new Faker({
locale: 'lv',
localeFallback: 'en',
Expand Down
2 changes: 2 additions & 0 deletions src/locale/mk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { Faker } from '../faker';
import en from '../locales/en';
import mk from '../locales/mk';

export { default } from '../locales/mk';

export const faker = new Faker({
locale: 'mk',
localeFallback: 'en',
Expand Down
Loading