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

i18n linting script (missing, extra) #2629

Merged
merged 6 commits into from
Apr 25, 2020
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/pr-any.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jobs:
pr:
strategy:
matrix:
step: ['lint', 'lint:css', 'test', 'build:code', 'build:i18n']
step: ['lint', 'lint:css', 'lint:i18n', 'test', 'build:code', 'build:i18n']
name: ${{ matrix.step }}
runs-on: ubuntu-latest
steps:
Expand Down
1 change: 0 additions & 1 deletion i18next-scanner.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ module.exports = {
options: {
debug: true,
defaultLng: 'en',
defaultNs: 'ui',
func: {
extensions: ['.tsx', '.ts'],
list: ['t', 'i18next.t', 'i18n.t']
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"clean:i18n": "rm -rf packages/apps/public/locales/en && mkdir -p packages/apps/public/locales/en",
"lint": "polkadot-dev-run-lint",
"lint:css": "stylelint './packages/**/src/**/*.tsx'",
"lint:i18n": "node ./scripts/i18nLint.js",
"postinstall": "polkadot-dev-yarn-only",
"test": "polkadot-dev-run-test packages/page-claims/src",
"test:one": "polkadot-dev-run-test",
Expand Down
190 changes: 99 additions & 91 deletions packages/apps-config/src/settings/endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,106 +4,114 @@

import { Option } from './types';

const DEV: Option[] = [
{
info: 'local',
text: 'Local Node (Own, 127.0.0.1:9944)',
value: 'ws://127.0.0.1:9944/'
}
];

const ENV: Option[] = [];
const WS_URL = process.env.WS_URL || (window as any).process_env?.WS_URL;

if (WS_URL) {
ENV.push({
info: 'WS_URL',
text: 'WS_URL: ' + WS_URL,
value: WS_URL
});
function createDev (t: (key: string, text: string, options: { ns: string }) => string): Option[] {
return [
{
info: 'local',
text: t('rpc.local', 'Local Node (Own, 127.0.0.1:9944)', { ns: 'apps-config' }),
value: 'ws://127.0.0.1:9944/'
}
];
}

const LIVE: Option[] = [
{
info: 'kusama',
text: 'Kusama (Polkadot Canary, hosted by Parity)',
value: 'wss://kusama-rpc.polkadot.io/'
},
{
info: 'kusama',
text: 'Kusama (Polkadot Canary, hosted by Web3 Foundation)',
value: 'wss://cc3-5.kusama.network/'
},
{
info: 'kusama',
text: 'Kusama (Load balanced between user-run public nodes; see https://status.cloud.ava.do/)',
value: 'wss://kusama.polkadot.cloud.ava.do/'
},
{
info: 'edgeware',
text: 'Edgeware (Edgeware Mainnet, hosted by Commonwealth Labs)',
value: 'wss://mainnet1.edgewa.re'
},
{
info: 'substrate',
text: 'Kulupu (Kulupu Mainnet, hosted by Kulupu)',
value: 'wss://rpc.kulupu.network/ws'
}
];

const TEST: Option[] = [
{
info: 'westend',
text: 'Westend (Polkadot Testnet, hosted by Parity)',
value: 'wss://westend-rpc.polkadot.io'
},
{
info: 'edgeware',
text: 'Berlin (Edgeware Testnet, hosted by Commonwealth Labs)',
value: 'wss://berlin1.edgewa.re'
},
{
info: 'substrate',
text: 'Flaming Fir (Substrate Testnet, hosted by Parity)',
value: 'wss://substrate-rpc.parity.io/'
}
];

let endpoints = [
{
isHeader: true,
text: 'Live networks',
value: ''
},
...LIVE,
{
isHeader: true,
text: 'Test networks',
value: ''
},
...TEST,
{
isHeader: true,
text: 'Development',
value: ''
},
...DEV
];
function createLive (t: (key: string, text: string, options: { ns: string }) => string): Option[] {
return [
{
info: 'kusama',
text: t('rpc.kusama.parity', 'Kusama (Polkadot Canary, hosted by Parity)', { ns: 'apps-config' }),
value: 'wss://kusama-rpc.polkadot.io/'
},
{
info: 'kusama',
text: t('rpc.kusama.w3f', 'Kusama (Polkadot Canary, hosted by Web3 Foundation)', { ns: 'apps-config' }),
value: 'wss://cc3-5.kusama.network/'
},
{
info: 'kusama',
text: t('rpc.kusama.ava', 'Kusama (Polkadot Canary, user-run public nodes; see https://status.cloud.ava.do/)', { ns: 'apps-config' }),
value: 'wss://kusama.polkadot.cloud.ava.do/'
},
{
info: 'edgeware',
text: t('rpc.edgeware', 'Edgeware (Edgeware Mainnet, hosted by Commonwealth Labs)', { ns: 'apps-config' }),
value: 'wss://mainnet1.edgewa.re'
},
{
info: 'substrate',
text: t('rpc.kulupu', 'Kulupu (Kulupu Mainnet, hosted by Kulupu)', { ns: 'apps-config' }),
value: 'wss://rpc.kulupu.network/ws'
}
];
}

if (ENV.length > 0) {
endpoints = [
function createTest (t: (key: string, text: string, options: { ns: string }) => string): Option[] {
return [
{
isHeader: true,
text: 'Custom ENV',
value: ''
info: 'westend',
text: t('rpc.westend', 'Westend (Polkadot Testnet, hosted by Parity)', { ns: 'apps-config' }),
value: 'wss://westend-rpc.polkadot.io'
},
{
info: 'edgeware',
text: t('rpc.berlin', 'Berlin (Edgeware Testnet, hosted by Commonwealth Labs)', { ns: 'apps-config' }),
value: 'wss://berlin1.edgewa.re'
},
...ENV
].concat(endpoints);
{
info: 'substrate',
text: t('rpc.flamingfir', 'Flaming Fir (Substrate Testnet, hosted by Parity)', { ns: 'apps-config' }),
value: 'wss://substrate-rpc.parity.io/'
}
];
}

// The available endpoints that will show in the dropdown. For the most part (with the exception of
// Polkadot) we try to keep this to live chains only, with RPCs hosted by the community/chain vendor
// info: The chain logo name as defined in ../logos, specifically in namedLogos
// text: The text to display on teh dropdown
// value: The actual hosted secure websocket endpoint
export default endpoints.map((option): Option => ({ ...option, withI18n: true }));
export default function create (t: (key: string, text: string, options: { ns: string }) => string): Option[] {
const ENV: Option[] = [];
const WS_URL = process.env.WS_URL || (window as any).process_env?.WS_URL;

if (WS_URL) {
ENV.push({
info: 'WS_URL',
text: 'WS_URL: ' + WS_URL,
value: WS_URL
});
}

let endpoints = [
{
isHeader: true,
text: t('rpc.header.live', 'Live networks', { ns: 'apps-config' }),
value: ''
},
...createLive(t),
{
isHeader: true,
text: t('rpc.header.test', 'Test networks', { ns: 'apps-config' }),
value: ''
},
...createTest(t),
{
isHeader: true,
text: t('rpc.header.dev', 'Development', { ns: 'apps-config' }),
value: ''
},
...createDev(t)
];

if (ENV.length > 0) {
endpoints = [
{
isHeader: true,
text: t('rpc.custom', 'Custom environment', { ns: 'apps-config' }),
value: ''
},
...ENV
].concat(endpoints);
}

return endpoints;
}
12 changes: 6 additions & 6 deletions packages/apps-config/src/settings/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.

import availableEndpoints from './endpoints';
import availableLanguages from './languages';
import availableSs58 from './ss58';
import createEndpoints from './endpoints';
import createLanguages from './languages';
import createSs58 from './ss58';

export {
availableEndpoints,
availableLanguages,
availableSs58
createEndpoints,
createLanguages,
createSs58
};
38 changes: 16 additions & 22 deletions packages/apps-config/src/settings/languages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,19 @@

import { Option } from './types';

// These are the available languages. For each there are translation files available
// in packages/apps/public/locales (Don't edit unless adding a new translation)
export default [
{
text: 'Default browser language (auto-detect)',
value: 'default',
withI18n: true
},
{
text: 'English',
value: 'en'
},
{
text: '汉语',
value: 'zh'
}
// For ja, we only have the settings page, remove until comprehensive
// , {
// text: '日本語',
// value: 'ja'
// }
].map((option): Option => ({ ...option }));
export default function create (t: (key: string, text: string, options: { ns: string }) => string): Option[] {
return [
{
text: t('lng.detect', 'Default browser language (auto-detect)', { ns: 'apps-config' }),
value: 'default'
},
{
text: 'English',
value: 'en'
},
{
text: '汉语',
value: 'zh'
}
];
}
66 changes: 34 additions & 32 deletions packages/apps-config/src/settings/ss58.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,37 @@ import { Option } from './types';
// info: the name of a logo as defined in ../logos, specifically in namedLogos
// text: The text you wish to display in the dropdown
// value: The actual ss5Format value (as registered)
export default [
{
info: 'default',
text: 'Default for the connected node',
value: -1
},
{
info: 'substrate',
text: 'Substrate (generic)',
value: 42
},
{
info: 'polkadot',
text: 'Polkadot (live)',
value: 0
},
{
info: 'kusama',
text: 'Kusama (canary)',
value: 2
},
{
info: 'edgeware',
text: 'Edgeware (live)',
value: 7
},
{
info: 'centrifuge',
text: 'Centrifuge (live)',
value: 36
}
].map((option): Option => ({ ...option, withI18n: true }));
export default function create (t: (key: string, text: string, options: { ns: string }) => string): Option[] {
return [
{
info: 'default',
text: t('ss58.default', 'Default for the connected node', { ns: 'apps-config' }),
value: -1
},
{
info: 'substrate',
text: t('ss58.substrate', 'Substrate (generic)', { ns: 'apps-config' }),
value: 42
},
{
info: 'polkadot',
text: t('ss58.polkadot', 'Polkadot (live)', { ns: 'apps-config' }),
value: 0
},
{
info: 'kusama',
text: t('ss58.kusmaa', 'Kusama (canary)', { ns: 'apps-config' }),
value: 2
},
{
info: 'edgeware',
text: t('ss58.edgeware', 'Edgeware (live)', { ns: 'apps-config' }),
value: 7
},
{
info: 'centrifuge',
text: t('ss58.centrifuge', 'Centrifuge (live)', { ns: 'apps-config' }),
value: 36
}
];
}
1 change: 0 additions & 1 deletion packages/apps-config/src/settings/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@ export interface Option {
isHeader?: boolean;
text: React.ReactNode;
value: string | number;
withI18n?: boolean;
}
Loading