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

Adjust i18n types (prepare for i18next-react update) #9688

Merged
merged 1 commit into from
Jul 13, 2023
Merged
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
10 changes: 3 additions & 7 deletions packages/apps-config/src/endpoints/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,10 @@ export { CUSTOM_ENDPOINT_KEY } from './development.js';
export * from './production.js';
export * from './testing.js';

function defaultT (keyOrText: string, text?: string, options?: TOptions): string {
function defaultT (keyOrText: string, text?: string | TOptions, options?: TOptions): string {
return (
(
options &&
options.replace &&
options.replace.host
) ||
text ||
(options?.replace?.host as string) ||
text?.toString() ||
keyOrText
);
}
Expand Down
4 changes: 2 additions & 2 deletions packages/apps-config/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

export interface TOptions {
ns?: string;
replace?: Record<string, string>
replace?: Record<string, unknown>
}

export type TFunction = (keyOrText: string, text?: string, options?: TOptions) => string;
export type TFunction = (keyOrText: string, textOrOptions?: string | TOptions, options?: TOptions) => string;
5 changes: 2 additions & 3 deletions packages/apps-routing/src/accounts.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// Copyright 2017-2023 @polkadot/apps-routing authors & contributors
// SPDX-License-Identifier: Apache-2.0

import type { TFunction } from 'i18next';
import type { Route } from './types.js';
import type { Route, TFunction } from './types.js';

import Component, { useCounter } from '@polkadot/app-accounts';

Expand All @@ -15,7 +14,7 @@ export default function create (t: TFunction): Route {
group: 'accounts',
icon: 'users',
name: 'accounts',
text: t<string>('nav.accounts', 'Accounts', { ns: 'apps-routing' }),
text: t('nav.accounts', 'Accounts', { ns: 'apps-routing' }),
useCounter
};
}
5 changes: 2 additions & 3 deletions packages/apps-routing/src/addresses.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// Copyright 2017-2023 @polkadot/apps-routing authors & contributors
// SPDX-License-Identifier: Apache-2.0

import type { TFunction } from 'i18next';
import type { Route } from './types.js';
import type { Route, TFunction } from './types.js';

import Component from '@polkadot/app-addresses';

Expand All @@ -15,6 +14,6 @@ export default function create (t: TFunction): Route {
group: 'accounts',
icon: 'address-card',
name: 'addresses',
text: t<string>('nav.addresses', 'Address book', { ns: 'apps-routing' })
text: t('nav.addresses', 'Address book', { ns: 'apps-routing' })
};
}
5 changes: 2 additions & 3 deletions packages/apps-routing/src/alliance.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// Copyright 2017-2023 @polkadot/apps-routing authors & contributors
// SPDX-License-Identifier: Apache-2.0

import type { TFunction } from 'i18next';
import type { Route } from './types.js';
import type { Route, TFunction } from './types.js';

import Component, { useCounter } from '@polkadot/app-alliance';

Expand All @@ -17,7 +16,7 @@ export default function create (t: TFunction): Route {
group: 'governance',
icon: 'people-group',
name: 'alliance',
text: t<string>('nav.alliance', 'Alliance', { ns: 'apps-routing' }),
text: t('nav.alliance', 'Alliance', { ns: 'apps-routing' }),
useCounter
};
}
5 changes: 2 additions & 3 deletions packages/apps-routing/src/assets.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// Copyright 2017-2023 @polkadot/apps-routing authors & contributors
// SPDX-License-Identifier: Apache-2.0

import type { TFunction } from 'i18next';
import type { Route } from './types.js';
import type { Route, TFunction } from './types.js';

import Component from '@polkadot/app-assets';

Expand All @@ -18,6 +17,6 @@ export default function create (t: TFunction): Route {
group: 'network',
icon: 'shopping-basket',
name: 'assets',
text: t<string>('nav.assets', 'Assets', { ns: 'apps-routing' })
text: t('nav.assets', 'Assets', { ns: 'apps-routing' })
};
}
5 changes: 2 additions & 3 deletions packages/apps-routing/src/bounties.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// Copyright 2017-2023 @polkadot/apps-routing authors & contributors
// SPDX-License-Identifier: Apache-2.0

import type { TFunction } from 'i18next';
import type { Route } from './types.js';
import type { Route, TFunction } from './types.js';

import Component, { useCounter } from '@polkadot/app-bounties';

Expand All @@ -17,7 +16,7 @@ export default function create (t: TFunction): Route {
group: 'governance',
icon: 'coins',
name: 'bounties',
text: t<string>('nav.bounties', 'Bounties', { ns: 'apps-routing' }),
text: t('nav.bounties', 'Bounties', { ns: 'apps-routing' }),
useCounter
};
}
5 changes: 2 additions & 3 deletions packages/apps-routing/src/calendar.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// Copyright 2017-2023 @polkadot/apps-routing authors & contributors
// SPDX-License-Identifier: Apache-2.0

import type { TFunction } from 'i18next';
import type { Route } from './types.js';
import type { Route, TFunction } from './types.js';

import Component from '@polkadot/app-calendar';

Expand All @@ -15,6 +14,6 @@ export default function create (t: TFunction): Route {
group: 'network',
icon: 'calendar-alt',
name: 'calendar',
text: t<string>('nav.calendar', 'Event calendar', { ns: 'apps-routing' })
text: t('nav.calendar', 'Event calendar', { ns: 'apps-routing' })
};
}
5 changes: 2 additions & 3 deletions packages/apps-routing/src/claims.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// Copyright 2017-2023 @polkadot/apps-routing authors & contributors
// SPDX-License-Identifier: Apache-2.0

import type { TFunction } from 'i18next';
import type { Route } from './types.js';
import type { Route, TFunction } from './types.js';

import Component, { useCounter } from '@polkadot/app-claims';

Expand All @@ -18,7 +17,7 @@ export default function create (t: TFunction): Route {
group: 'accounts',
icon: 'star',
name: 'claims',
text: t<string>('nav.claims', 'Claim Tokens', { ns: 'apps-routing' }),
text: t('nav.claims', 'Claim Tokens', { ns: 'apps-routing' }),
useCounter
};
}
5 changes: 2 additions & 3 deletions packages/apps-routing/src/collator.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// Copyright 2017-2023 @polkadot/apps-routing authors & contributors
// SPDX-License-Identifier: Apache-2.0

import type { TFunction } from 'i18next';
import type { Route } from './types.js';
import type { Route, TFunction } from './types.js';

import Component from '@polkadot/app-collator';

Expand All @@ -17,6 +16,6 @@ export default function create (t: TFunction): Route {
group: 'network',
icon: 'timeline',
name: 'collators',
text: t<string>('nav.collator', 'Collators', { ns: 'apps-routing' })
text: t('nav.collator', 'Collators', { ns: 'apps-routing' })
};
}
5 changes: 2 additions & 3 deletions packages/apps-routing/src/contracts.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
// Copyright 2017-2023 @polkadot/apps-routing authors & contributors
// SPDX-License-Identifier: Apache-2.0

import type { TFunction } from 'i18next';
import type { ApiPromise } from '@polkadot/api';
import type { Route } from './types.js';
import type { Route, TFunction } from './types.js';

import Component from '@polkadot/app-contracts';
import { assertReturn } from '@polkadot/util';
Expand Down Expand Up @@ -32,6 +31,6 @@ export default function create (t: TFunction): Route {
group: 'developer',
icon: 'compress',
name: 'contracts',
text: t<string>('nav.contracts', 'Contracts', { ns: 'apps-routing' })
text: t('nav.contracts', 'Contracts', { ns: 'apps-routing' })
};
}
5 changes: 2 additions & 3 deletions packages/apps-routing/src/council.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// Copyright 2017-2023 @polkadot/apps-routing authors & contributors
// SPDX-License-Identifier: Apache-2.0

import type { TFunction } from 'i18next';
import type { Route } from './types.js';
import type { Route, TFunction } from './types.js';

import Component, { useCounter } from '@polkadot/app-council';

Expand All @@ -18,7 +17,7 @@ export default function create (t: TFunction): Route {
group: 'governance',
icon: 'building',
name: 'council',
text: t<string>('nav.council', 'Council', { ns: 'apps-routing' }),
text: t('nav.council', 'Council', { ns: 'apps-routing' }),
useCounter
};
}
5 changes: 2 additions & 3 deletions packages/apps-routing/src/democracy.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
// Copyright 2017-2023 @polkadot/apps-routing authors & contributors
// SPDX-License-Identifier: Apache-2.0

import type { TFunction } from 'i18next';
import type { ApiPromise } from '@polkadot/api';
import type { Route } from './types.js';
import type { Route, TFunction } from './types.js';

import Component, { useCounter } from '@polkadot/app-democracy';

Expand Down Expand Up @@ -32,7 +31,7 @@ export default function create (t: TFunction): Route {
group: 'governance',
icon: 'calendar-check',
name: 'democracy',
text: t<string>('nav.democracy', 'Democracy', { ns: 'apps-routing' }),
text: t('nav.democracy', 'Democracy', { ns: 'apps-routing' }),
useCounter
};
}
5 changes: 2 additions & 3 deletions packages/apps-routing/src/explorer.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// Copyright 2017-2023 @polkadot/apps-routing authors & contributors
// SPDX-License-Identifier: Apache-2.0

import type { TFunction } from 'i18next';
import type { Route } from './types.js';
import type { Route, TFunction } from './types.js';

import Component from '@polkadot/app-explorer';

Expand All @@ -15,6 +14,6 @@ export default function create (t: TFunction): Route {
group: 'network',
icon: 'braille',
name: 'explorer',
text: t<string>('nav.explorer', 'Explorer', { ns: 'apps-routing' })
text: t('nav.explorer', 'Explorer', { ns: 'apps-routing' })
};
}
5 changes: 2 additions & 3 deletions packages/apps-routing/src/extrinsics.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// Copyright 2017-2023 @polkadot/apps-routing authors & contributors
// SPDX-License-Identifier: Apache-2.0

import type { TFunction } from 'i18next';
import type { Route } from './types.js';
import type { Route, TFunction } from './types.js';

import Component from '@polkadot/app-extrinsics';

Expand All @@ -16,6 +15,6 @@ export default function create (t: TFunction): Route {
group: 'developer',
icon: 'envelope-open-text',
name: 'extrinsics',
text: t<string>('nav.extrinsics', 'Extrinsics', { ns: 'apps-routing' })
text: t('nav.extrinsics', 'Extrinsics', { ns: 'apps-routing' })
};
}
5 changes: 2 additions & 3 deletions packages/apps-routing/src/fellowship.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// Copyright 2017-2023 @polkadot/apps-routing authors & contributors
// SPDX-License-Identifier: Apache-2.0

import type { TFunction } from 'i18next';
import type { Route } from './types.js';
import type { Route, TFunction } from './types.js';

import Component, { useCounter } from '@polkadot/app-fellowship';

Expand All @@ -20,7 +19,7 @@ export default function create (t: TFunction): Route {
group: 'governance',
icon: 'people-arrows',
name: 'fellowship',
text: t<string>('nav.fellowship', 'Fellowship', { ns: 'apps-routing' }),
text: t('nav.fellowship', 'Fellowship', { ns: 'apps-routing' }),
useCounter
};
}
5 changes: 2 additions & 3 deletions packages/apps-routing/src/files.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// Copyright 2017-2023 @polkadot/apps-routing authors & contributors
// SPDX-License-Identifier: Apache-2.0

import type { TFunction } from 'i18next';
import type { Route } from './types.js';
import type { Route, TFunction } from './types.js';

import Component from '@polkadot/app-files';

Expand All @@ -16,6 +15,6 @@ export default function create (t: TFunction): Route {
group: 'developer',
icon: 'file',
name: 'files',
text: t<string>('nav.files', 'Files (IPFS)', { ns: 'apps-routing' })
text: t('nav.files', 'Files (IPFS)', { ns: 'apps-routing' })
};
}
5 changes: 2 additions & 3 deletions packages/apps-routing/src/gilt.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// Copyright 2017-2023 @polkadot/apps-routing authors & contributors
// SPDX-License-Identifier: Apache-2.0

import type { TFunction } from 'i18next';
import type { Route } from './types.js';
import type { Route, TFunction } from './types.js';

import Component from '@polkadot/app-gilt';

Expand All @@ -18,6 +17,6 @@ export default function create (t: TFunction): Route {
group: 'network',
icon: 'leaf',
name: 'gilt',
text: t<string>('nav.gilt', 'Gilt', { ns: 'apps-routing' })
text: t('nav.gilt', 'Gilt', { ns: 'apps-routing' })
};
}
3 changes: 1 addition & 2 deletions packages/apps-routing/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// Copyright 2017-2023 @polkadot/apps-routing authors & contributors
// SPDX-License-Identifier: Apache-2.0

import type { TFunction } from 'i18next';
import type { Routes } from './types.js';
import type { Routes, TFunction } from './types.js';

import accounts from './accounts.js';
import addresses from './addresses.js';
Expand Down
5 changes: 2 additions & 3 deletions packages/apps-routing/src/js.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// Copyright 2017-2023 @polkadot/apps-routing authors & contributors
// SPDX-License-Identifier: Apache-2.0

import type { TFunction } from 'i18next';
import type { Route } from './types.js';
import type { Route, TFunction } from './types.js';

import Component from '@polkadot/app-js';

Expand All @@ -15,6 +14,6 @@ export default function create (t: TFunction): Route {
group: 'developer',
icon: 'code',
name: 'js',
text: t<string>('nav.js', 'JavaScript', { ns: 'apps-routing' })
text: t('nav.js', 'JavaScript', { ns: 'apps-routing' })
};
}
5 changes: 2 additions & 3 deletions packages/apps-routing/src/membership.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// Copyright 2017-2023 @polkadot/apps-routing authors & contributors
// SPDX-License-Identifier: Apache-2.0

import type { TFunction } from 'i18next';
import type { Route } from './types.js';
import type { Route, TFunction } from './types.js';

import Component, { useCounter } from '@polkadot/app-membership';

Expand All @@ -18,7 +17,7 @@ export default function create (t: TFunction): Route {
group: 'governance',
icon: 'people-carry',
name: 'membership',
text: t<string>('nav.membership', 'Membership', { ns: 'apps-routing' }),
text: t('nav.membership', 'Membership', { ns: 'apps-routing' }),
useCounter
};
}
5 changes: 2 additions & 3 deletions packages/apps-routing/src/nfts.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// Copyright 2017-2023 @polkadot/apps-routing authors & contributors
// SPDX-License-Identifier: Apache-2.0

import type { TFunction } from 'i18next';
import type { Route } from './types.js';
import type { Route, TFunction } from './types.js';

import Component from '@polkadot/app-nfts';

Expand All @@ -17,6 +16,6 @@ export default function create (t: TFunction): Route {
group: 'network',
icon: 'shopping-cart',
name: 'nfts',
text: t<string>('nav.nfts', 'NFTs', { ns: 'apps-routing' })
text: t('nav.nfts', 'NFTs', { ns: 'apps-routing' })
};
}
Loading