Skip to content
Open
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
22 changes: 22 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"homepage": "https://github.com/0xcap/client-v3#readme",
"devDependencies": {
"@rollup/plugin-commonjs": "^21.0.1",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^13.0.6",
"ethers": "^5.5.1",
"rollup": "^2.58.0",
Expand Down
4 changes: 3 additions & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import svelte from 'rollup-plugin-svelte';
import commonjs from '@rollup/plugin-commonjs';
import json from '@rollup/plugin-json';
import resolve from '@rollup/plugin-node-resolve';
import livereload from 'rollup-plugin-livereload';
import { terser } from 'rollup-plugin-terser';
Expand Down Expand Up @@ -47,6 +48,7 @@ export default {
dev: !production
}
}),
json(),

production && gzipPlugin(),
production && gzipPlugin({
Expand Down Expand Up @@ -103,4 +105,4 @@ export default {
usePolling: true
}
}
};
};
1 change: 1 addition & 0 deletions src/labels/EN.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
6 changes: 6 additions & 0 deletions src/lib/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,10 @@ export const CHAINDATA = {
}
}

// Languages

export const LANG = {
EN: "EN",
};

export const LANG_DEFAULT = LANG.EN;
29 changes: 29 additions & 0 deletions src/lib/labels.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import EN from '../labels/EN.json';

import { derived } from 'svelte/store';

import { LANG_DEFAULT } from './constants';
import { language as lang } from './stores';

const LABELS = {
EN,
};

function dig(obj, keys) {
let current = obj;
for (const key of keys) {
if (key in current) {
current = current[key];
} else {
return;
}
}
return current;
}

function find(lang, label) {
const keys = label.split('.');
return dig(LABELS[lang], keys) || dig(LABELS[LANG_DEFAULT], keys);
}

export const L = derived([lang], ($lang) => (label) => find($lang, label));
7 changes: 6 additions & 1 deletion src/lib/stores.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { writable, derived } from 'svelte/store'

import { LANG_DEFAULT } from './constants'

// History
export const history = writable([]);

Expand Down Expand Up @@ -60,4 +62,7 @@ export const address = writable(null);

export const allowances = writable({});

export const wrongNetwork = writable(false);
export const wrongNetwork = writable(false);

// Language
export const language = writable(LANG_DEFAULT);