Skip to content

Commit e9691fb

Browse files
authored
refactor(types): rename locale definition types to singular (#2058)
1 parent b72d52e commit e9691fb

File tree

514 files changed

+1159
-1130
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

514 files changed

+1159
-1130
lines changed

scripts/generateLocales.ts

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import { resolve } from 'node:path';
2323
import type { Options } from 'prettier';
2424
import { format } from 'prettier';
2525
import options from '../.prettierrc.cjs';
26-
import type { LocaleDefinition, MetadataDefinitions } from '../src/definitions';
26+
import type { LocaleDefinition, MetadataDefinition } from '../src/definitions';
2727

2828
// Constants
2929

@@ -44,34 +44,34 @@ type PascalCase<S extends string> = S extends `${infer P1}_${infer P2}`
4444
? `${Capitalize<P1>}${PascalCase<P2>}`
4545
: Capitalize<S>;
4646

47-
type DefinitionsType = {
48-
[key in keyof LocaleDefinition]-?: PascalCase<`${key}Definitions`>;
47+
type DefinitionType = {
48+
[key in keyof LocaleDefinition]-?: PascalCase<`${key}Definition`>;
4949
};
5050

5151
/**
5252
* The types of the definitions.
5353
*/
54-
const definitionsTypes: DefinitionsType = {
55-
airline: 'AirlineDefinitions',
56-
animal: 'AnimalDefinitions',
57-
color: 'ColorDefinitions',
58-
commerce: 'CommerceDefinitions',
59-
company: 'CompanyDefinitions',
60-
database: 'DatabaseDefinitions',
61-
date: 'DateDefinitions',
62-
finance: 'FinanceDefinitions',
63-
hacker: 'HackerDefinitions',
64-
internet: 'InternetDefinitions',
65-
location: 'LocationDefinitions',
66-
lorem: 'LoremDefinitions',
67-
metadata: 'MetadataDefinitions',
68-
music: 'MusicDefinitions',
69-
person: 'PersonDefinitions',
70-
phone_number: 'PhoneNumberDefinitions',
71-
science: 'ScienceDefinitions',
72-
system: 'SystemDefinitions',
73-
vehicle: 'VehicleDefinitions',
74-
word: 'WordDefinitions',
54+
const definitionsTypes: DefinitionType = {
55+
airline: 'AirlineDefinition',
56+
animal: 'AnimalDefinition',
57+
color: 'ColorDefinition',
58+
commerce: 'CommerceDefinition',
59+
company: 'CompanyDefinition',
60+
database: 'DatabaseDefinition',
61+
date: 'DateDefinition',
62+
finance: 'FinanceDefinition',
63+
hacker: 'HackerDefinition',
64+
internet: 'InternetDefinition',
65+
location: 'LocationDefinition',
66+
lorem: 'LoremDefinition',
67+
metadata: 'MetadataDefinition',
68+
music: 'MusicDefinition',
69+
person: 'PersonDefinition',
70+
phone_number: 'PhoneNumberDefinition',
71+
science: 'ScienceDefinition',
72+
system: 'SystemDefinition',
73+
vehicle: 'VehicleDefinition',
74+
word: 'WordDefinition',
7575
};
7676

7777
const prettierTsOptions: Options = { ...options, parser: 'typescript' };
@@ -281,7 +281,7 @@ for (const locale of locales) {
281281
let localeTitle = 'No title found';
282282
try {
283283
// eslint-disable-next-line @typescript-eslint/no-var-requires
284-
const metadata: MetadataDefinitions = require(pathMetadata).default;
284+
const metadata: MetadataDefinition = require(pathMetadata).default;
285285
const { title } = metadata;
286286
if (!title) {
287287
throw new Error(`No title property found on ${JSON.stringify(metadata)}`);
@@ -290,7 +290,7 @@ for (const locale of locales) {
290290
localeTitle = title;
291291
} catch (e) {
292292
console.error(
293-
`Failed to load ${pathMetadata}. Please make sure the file exists and exports MetadataDefinitions.`
293+
`Failed to load ${pathMetadata}. Please make sure the file exists and exports a MetadataDefinition.`
294294
);
295295
console.error(e);
296296
}

src/definitions/airline.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { Airline, Airplane, Airport } from '../modules/airline';
22
import type { LocaleEntry } from './definitions';
33

4-
export type AirlineDefinitions = LocaleEntry<{
4+
export type AirlineDefinition = LocaleEntry<{
55
/**
66
* Some airline information
77
*/

src/definitions/animal.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { LocaleEntry } from './definitions';
33
/**
44
* The possible definitions related to animals.
55
*/
6-
export type AnimalDefinitions = LocaleEntry<{
6+
export type AnimalDefinition = LocaleEntry<{
77
bear: string[];
88
bird: string[];
99
cat: string[];

src/definitions/color.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { LocaleEntry } from './definitions';
33
/**
44
* The possible definitions related to colors.
55
*/
6-
export type ColorDefinitions = LocaleEntry<{
6+
export type ColorDefinition = LocaleEntry<{
77
/**
88
* Human readable color names.
99
*/

src/definitions/commerce.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { LocaleEntry } from './definitions';
33
/**
44
* The possible definitions related to commerce.
55
*/
6-
export type CommerceDefinitions = LocaleEntry<{
6+
export type CommerceDefinition = LocaleEntry<{
77
/**
88
* Department names inside a shop.
99
*/
@@ -12,7 +12,7 @@ export type CommerceDefinitions = LocaleEntry<{
1212
/**
1313
* Product name generation definitions.
1414
*/
15-
product_name: CommerceProductNameDefinitions;
15+
product_name: CommerceProductNameDefinition;
1616

1717
/**
1818
* Descriptions for products.
@@ -23,7 +23,7 @@ export type CommerceDefinitions = LocaleEntry<{
2323
/**
2424
* The possible definitions related to product name generation.
2525
*/
26-
export interface CommerceProductNameDefinitions {
26+
export interface CommerceProductNameDefinition {
2727
/**
2828
* Adjectives describing a product (e.g. tasty).
2929
*/

src/definitions/company.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { LocaleEntry } from './definitions';
33
/**
44
* The possible definitions related to companies.
55
*/
6-
export type CompanyDefinitions = LocaleEntry<{
6+
export type CompanyDefinition = LocaleEntry<{
77
/**
88
* Business/products related adjectives that can be used to demonstrate data being viewed by a manager.
99
*/

src/definitions/database.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { LocaleEntry } from './definitions';
33
/**
44
* The possible definitions related to databases.
55
*/
6-
export type DatabaseDefinitions = LocaleEntry<{
6+
export type DatabaseDefinition = LocaleEntry<{
77
/**
88
* Database engines.
99
*/

src/definitions/date.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { LocaleEntry } from './definitions';
33
/**
44
* The possible definitions related to dates.
55
*/
6-
export type DateDefinitions = LocaleEntry<{
6+
export type DateDefinition = LocaleEntry<{
77
/**
88
* The translations for months (January - December).
99
*/

src/definitions/definitions.ts

Lines changed: 40 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
import type { AirlineDefinitions } from './airline';
2-
import type { AnimalDefinitions } from './animal';
3-
import type { ColorDefinitions } from './color';
4-
import type { CommerceDefinitions } from './commerce';
5-
import type { CompanyDefinitions } from './company';
6-
import type { DatabaseDefinitions } from './database';
7-
import type { DateDefinitions } from './date';
8-
import type { FinanceDefinitions } from './finance';
9-
import type { HackerDefinitions } from './hacker';
10-
import type { InternetDefinitions } from './internet';
11-
import type { LocationDefinitions } from './location';
12-
import type { LoremDefinitions } from './lorem';
13-
import type { MetadataDefinitions } from './metadata';
14-
import type { MusicDefinitions } from './music';
15-
import type { PersonDefinitions } from './person';
16-
import type { PhoneNumberDefinitions } from './phone_number';
17-
import type { ScienceDefinitions } from './science';
18-
import type { SystemDefinitions } from './system';
19-
import type { VehicleDefinitions } from './vehicle';
20-
import type { WordDefinitions } from './word';
1+
import type { AirlineDefinition } from './airline';
2+
import type { AnimalDefinition } from './animal';
3+
import type { ColorDefinition } from './color';
4+
import type { CommerceDefinition } from './commerce';
5+
import type { CompanyDefinition } from './company';
6+
import type { DatabaseDefinition } from './database';
7+
import type { DateDefinition } from './date';
8+
import type { FinanceDefinition } from './finance';
9+
import type { HackerDefinition } from './hacker';
10+
import type { InternetDefinition } from './internet';
11+
import type { LocationDefinition } from './location';
12+
import type { LoremDefinition } from './lorem';
13+
import type { MetadataDefinition } from './metadata';
14+
import type { MusicDefinition } from './music';
15+
import type { PersonDefinition } from './person';
16+
import type { PhoneNumberDefinition } from './phone_number';
17+
import type { ScienceDefinition } from './science';
18+
import type { SystemDefinition } from './system';
19+
import type { VehicleDefinition } from './vehicle';
20+
import type { WordDefinition } from './word';
2121

2222
/**
2323
* Wrapper type for all definition categories that will make all properties optional and allow extra properties.
@@ -28,28 +28,26 @@ export type LocaleEntry<T extends Record<string, unknown>> = {
2828

2929
/**
3030
* The definitions as used by the translations/locales.
31-
* This is basically the same as Definitions with the exception,
32-
* that most properties are optional and extra properties are allowed.
3331
*/
3432
export type LocaleDefinition = {
35-
metadata?: MetadataDefinitions;
36-
airline?: AirlineDefinitions;
37-
animal?: AnimalDefinitions;
38-
color?: ColorDefinitions;
39-
commerce?: CommerceDefinitions;
40-
company?: CompanyDefinitions;
41-
database?: DatabaseDefinitions;
42-
date?: DateDefinitions;
43-
finance?: FinanceDefinitions;
44-
hacker?: HackerDefinitions;
45-
internet?: InternetDefinitions;
46-
location?: LocationDefinitions;
47-
lorem?: LoremDefinitions;
48-
music?: MusicDefinitions;
49-
person?: PersonDefinitions;
50-
phone_number?: PhoneNumberDefinitions;
51-
science?: ScienceDefinitions;
52-
system?: SystemDefinitions;
53-
vehicle?: VehicleDefinitions;
54-
word?: WordDefinitions;
33+
metadata?: MetadataDefinition;
34+
airline?: AirlineDefinition;
35+
animal?: AnimalDefinition;
36+
color?: ColorDefinition;
37+
commerce?: CommerceDefinition;
38+
company?: CompanyDefinition;
39+
database?: DatabaseDefinition;
40+
date?: DateDefinition;
41+
finance?: FinanceDefinition;
42+
hacker?: HackerDefinition;
43+
internet?: InternetDefinition;
44+
location?: LocationDefinition;
45+
lorem?: LoremDefinition;
46+
music?: MusicDefinition;
47+
person?: PersonDefinition;
48+
phone_number?: PhoneNumberDefinition;
49+
science?: ScienceDefinition;
50+
system?: SystemDefinition;
51+
vehicle?: VehicleDefinition;
52+
word?: WordDefinition;
5553
} & Record<string, Record<string, unknown> | undefined>;

src/definitions/finance.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { LocaleEntry } from './definitions';
33
/**
44
* The possible definitions related to finance.
55
*/
6-
export type FinanceDefinitions = LocaleEntry<{
6+
export type FinanceDefinition = LocaleEntry<{
77
/**
88
* The types of accounts/purposes of an account (e.g. `Savings` account).
99
*/

src/definitions/hacker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { LocaleEntry } from './definitions';
33
/**
44
* The possible definitions related to computers.
55
*/
6-
export type HackerDefinitions = LocaleEntry<{
6+
export type HackerDefinition = LocaleEntry<{
77
/**
88
* Generic computer related abbreviations (e.g. `RAM`, `EXE`).
99
*/

src/definitions/index.ts

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,24 @@
1-
export type { AirlineDefinitions } from './airline';
2-
export type { AnimalDefinitions } from './animal';
3-
export type { ColorDefinitions } from './color';
1+
export type { AirlineDefinition } from './airline';
2+
export type { AnimalDefinition } from './animal';
3+
export type { ColorDefinition } from './color';
44
export type {
5-
CommerceDefinitions,
6-
CommerceProductNameDefinitions,
5+
CommerceDefinition,
6+
CommerceProductNameDefinition,
77
} from './commerce';
8-
export type { CompanyDefinitions } from './company';
9-
export type { DatabaseDefinitions } from './database';
10-
export type { DateDefinitions, DateEntryDefinition } from './date';
8+
export type { CompanyDefinition } from './company';
9+
export type { DatabaseDefinition } from './database';
10+
export type { DateDefinition, DateEntryDefinition } from './date';
1111
export type { LocaleDefinition, LocaleEntry } from './definitions';
12-
export type { FinanceDefinitions } from './finance';
13-
export type { HackerDefinitions } from './hacker';
14-
export type { InternetDefinitions } from './internet';
15-
export type { LocationDefinitions } from './location';
16-
export type { LoremDefinitions } from './lorem';
17-
export type { MetadataDefinitions } from './metadata';
18-
export type { MusicDefinitions } from './music';
19-
export type { PersonDefinitions, PersonTitleDefinitions } from './person';
20-
export type { PhoneNumberDefinitions } from './phone_number';
21-
export type { ScienceDefinitions } from './science';
22-
export type {
23-
SystemDefinitions,
24-
SystemMimeTypeEntryDefinitions,
25-
} from './system';
26-
export type { VehicleDefinitions } from './vehicle';
27-
export type { WordDefinitions } from './word';
12+
export type { FinanceDefinition } from './finance';
13+
export type { HackerDefinition } from './hacker';
14+
export type { InternetDefinition } from './internet';
15+
export type { LocationDefinition } from './location';
16+
export type { LoremDefinition } from './lorem';
17+
export type { MetadataDefinition } from './metadata';
18+
export type { MusicDefinition } from './music';
19+
export type { PersonDefinition, PersonTitleDefinition } from './person';
20+
export type { PhoneNumberDefinition } from './phone_number';
21+
export type { ScienceDefinition } from './science';
22+
export type { SystemDefinition, SystemMimeTypeEntryDefinition } from './system';
23+
export type { VehicleDefinition } from './vehicle';
24+
export type { WordDefinition } from './word';

src/definitions/internet.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type { LocaleEntry } from './definitions';
44
/**
55
* The possible definitions related to internet stuff.
66
*/
7-
export type InternetDefinitions = LocaleEntry<{
7+
export type InternetDefinition = LocaleEntry<{
88
/**
99
* Common top level and similar domains (e.g `de`, `co.uk`).
1010
*/

src/definitions/location.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { LocaleEntry } from './definitions';
33
/**
44
* The possible definitions related to addresses and locations.
55
*/
6-
export type LocationDefinitions = LocaleEntry<{
6+
export type LocationDefinition = LocaleEntry<{
77
/**
88
* Postcodes patterns by state
99
*/

src/definitions/lorem.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { LocaleEntry } from './definitions';
33
/**
44
* The possible definitions related to lorem texts.
55
*/
6-
export type LoremDefinitions = LocaleEntry<{
6+
export type LoremDefinition = LocaleEntry<{
77
/**
88
* Lorem words used to generate dummy texts.
99
*/

src/definitions/metadata.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { LocaleEntry } from './definitions';
33
/**
44
* Metadata for pre-built locales.
55
*/
6-
export type PreBuiltMetadataDefinitions = {
6+
export type PreBuiltMetadataDefinition = {
77
/**
88
* The English name of the language (and the specific country, if defined).
99
*/
@@ -43,8 +43,8 @@ export type PreBuiltMetadataDefinitions = {
4343
/**
4444
* Metadata for pre-built locales for a specific country.
4545
*/
46-
export type PreBuiltMetadataDefinitionsForCountry =
47-
PreBuiltMetadataDefinitions & {
46+
export type PreBuiltMetadataDefinitionForCountry =
47+
PreBuiltMetadataDefinition & {
4848
/**
4949
* The ISO 3166-1 alpha-2 code of the country.
5050
*
@@ -56,5 +56,5 @@ export type PreBuiltMetadataDefinitionsForCountry =
5656
/**
5757
* Metadata for the current locale.
5858
*/
59-
export type MetadataDefinitions =
60-
LocaleEntry<PreBuiltMetadataDefinitionsForCountry>;
59+
export type MetadataDefinition =
60+
LocaleEntry<PreBuiltMetadataDefinitionForCountry>;

src/definitions/music.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { LocaleEntry } from './definitions';
33
/**
44
* The possible definitions related to music.
55
*/
6-
export type MusicDefinitions = LocaleEntry<{
6+
export type MusicDefinition = LocaleEntry<{
77
/**
88
* The names of some music genres.
99
*/

0 commit comments

Comments
 (0)