diff options
| author | secondl1ght <[email protected]> | 2022-08-24 19:51:31 -0400 |
|---|---|---|
| committer | secondl1ght <[email protected]> | 2022-08-24 19:51:31 -0400 |
| commit | f6ff5156b66efbb51ba046e37de65b466585124a (patch) | |
| tree | 6fed2233ad80097cd75a2a0340f199f2c564eef0 | |
| parent | 8f8f85983d2f4cb734ed15b33ebc140028711733 (diff) | |
| download | coinos-ui-f6ff5156b66efbb51ba046e37de65b466585124a.tar.gz coinos-ui-f6ff5156b66efbb51ba046e37de65b466585124a.zip | |
remove duplicate elements and format
| -rw-r--r-- | doc/i18n-technical.md | 4 | ||||
| -rw-r--r-- | doc/i18n.md | 27 | ||||
| -rw-r--r-- | src/components/About.svelte | 18 | ||||
| -rw-r--r-- | src/lib/translations/index.js | 46 | ||||
| -rw-r--r-- | src/routes/+layout.svelte | 4 | ||||
| -rw-r--r-- | src/routes/[username]/dashboard/+page.svelte | 13 | ||||
| -rw-r--r-- | src/routes/invoice/+server.js | 2 | ||||
| -rw-r--r-- | src/routes/invoice/[id]/+page.server.js | 1 |
8 files changed, 49 insertions, 66 deletions
diff --git a/doc/i18n-technical.md b/doc/i18n-technical.md index 46fbb094..51e33fe6 100644 --- a/doc/i18n-technical.md +++ b/doc/i18n-technical.md @@ -13,9 +13,9 @@ CoinOS's internationalization system depends on the `npm` package [`sveltekit-i1 The main code for CoinOS's internationalization is at `src/lib/translations/index.js`. When imported, it does the following: 1. Load all of the locales asynchronously, based on . -3. Initialize `sveltekit-i18n`. +2. Initialize `sveltekit-i18n`. -It also defines important constants, including the list of available locales and the default locale. This code is loaded by importing `$lib/translations` in `src/routes/+layout.svelte`. This code, which runs in the frontend, also persists the locale in `localStorage`. +It also defines important constants, including the list of available locales and the default locale. This code is loaded by importing `$lib/translations` in `src/routes/+layout.svelte`. This code, which runs in the frontend, also persists the locale in `localStorage`. ## Locale Files diff --git a/doc/i18n.md b/doc/i18n.md index f33ab2de..528f611b 100644 --- a/doc/i18n.md +++ b/doc/i18n.md @@ -4,7 +4,7 @@ CoinOS can be translated into other languages by editing [JSON](https://www.json _NOTE: This guide was written for people without a technical background. If you want more technical details, click [here](./i18n-technical.md)._ -These instructions assume you have a GitHub account and have permission to modify this repository. If you do not have permission, you will need to [make a fork](https://github.com/coinos/coinos-ui-v2/fork) using the link on the top-right, then follow these instructions to translate your fork, then make a pull request using the link below the "Code" button to apply your changes to the main repository. +These instructions assume you have a GitHub account and have permission to modify this repository. If you do not have permission, you will need to [make a fork](https://github.com/coinos/coinos-ui-v2/fork) using the link on the top-right, then follow these instructions to translate your fork, then make a pull request using the link below the "Code" button to apply your changes to the main repository. Last Updated: 2022-08-23 @@ -32,7 +32,7 @@ Each line (other than the opening and closing braces) contains a **text name**, ### The Language List -There is also a JSON file that controls which languages are understood. It is at `src/lib/translations/lang.json` and looks something like this: +There is also a JSON file that controls which languages are understood. It is at `src/lib/translations/lang.json` and looks something like this: ```JSON { @@ -42,7 +42,7 @@ There is also a JSON file that controls which languages are understood. It is a } ``` -This file simply maps each language to its name. It is used both to get a list of languages and to get the name of each language for the language selector. If a translation is not in this file, CoinOS will not be able to see it. +This file simply maps each language to its name. It is used both to get a list of languages and to get the name of each language for the language selector. If a translation is not in this file, CoinOS will not be able to see it. ### JSON Sections @@ -60,12 +60,12 @@ You might notice that some of the left-text in the language files don't have a s }, ``` -These denote sections of the JSON file, which helps keep it organized. If you're translating some text that is in a section, make sure the translated text is in the same section of the new file. If that section doesn't exist, just create it. +These denote sections of the JSON file, which helps keep it organized. If you're translating some text that is in a section, make sure the translated text is in the same section of the new file. If that section doesn't exist, just create it. -In the translation files, sections roughly correspond to where the the text is in CoinOS. This can be useful if you need context for some text. Here are some of these associations (`A.B` means section `B` is located inside `A`): +In the translation files, sections roughly correspond to where the the text is in CoinOS. This can be useful if you need context for some text. Here are some of these associations (`A.B` means section `B` is located inside `A`): | Section | Location | -|-------------------|---------------------------------------------------| +| ----------------- | ------------------------------------------------- | | 404 | the 404 page | | about | the 'About' section at the bottom of the homepage | | error | the error page | @@ -84,15 +84,15 @@ In the translation files, sections roughly correspond to where the the text is i ### HTML Tags -Sometimes, you will see strange text surrounded with `<>` angle brackets. Every one of these "HTML tags" will be followed by another one starting with a slash. Here's an example: +Sometimes, you will see strange text surrounded with `<>` angle brackets. Every one of these "HTML tags" will be followed by another one starting with a slash. Here's an example: ```JSON "p1": "<strong>CoinOS</strong> is an <strong>open source</strong> bitcoin web wallet, point of sale, ecommerce marketplace and exchange platform. Development started in Vancouver in September 2012 as a way to provide local merchants with a convenient way to accept bitcoin payments.", ``` -These apply a certain style to the text between them. For example, the tags above will make "CoinOS" and "open source" bold, leaving the rest non-bold. +These apply a certain style to the text between them. For example, the tags above will make "CoinOS" and "open source" bold, leaving the rest non-bold. -When translating strings containing tags, don't change the tags. Do translate the text between them, and don't be afraid to move them around - just make sure they contain the same part of the sentence, and that the one without the slash is always before the one with the slash. Not all of the localizable strings support HTML tags, so you shouldn't use them if they aren't in the original string you're translating. +When translating strings containing tags, don't change the tags. Do translate the text between them, and don't be afraid to move them around - just make sure they contain the same part of the sentence, and that the one without the slash is always before the one with the slash. Not all of the localizable strings support HTML tags, so you shouldn't use them if they aren't in the original string you're translating. ## Creating a New Translation @@ -107,7 +107,7 @@ Follow these steps to create a new translation. You will need a GitHub account t  5. Scroll down and use the green button to commit the file. 6. Go to the `src` folder again, then `lib`, then `translations`, then `lang.json`. -7. Use the pencil icon on the top-right to edit the file, then add a new line containing your language code in quotes, followed by a colon, followed by the full name of your language in quotes. Make sure every line except the last has a comma at the end. +7. Use the pencil icon on the top-right to edit the file, then add a new line containing your language code in quotes, followed by a colon, followed by the full name of your language in quotes. Make sure every line except the last has a comma at the end. 8. Commit your changes like you did in step 5. ## Adding to an Existing Translation @@ -127,10 +127,11 @@ Follow these steps to add to an existing translation. You will also need a GitHu ## The Guided Translation Script -There is also a program that helps you translate automatically - all you have to do is input the translated text and it will do the rest for you! You need a bit of technical knowledge to use it however, specifically, you need to know: +There is also a program that helps you translate automatically - all you have to do is input the translated text and it will do the rest for you! You need a bit of technical knowledge to use it however, specifically, you need to know: + - How to use basic [git](https://git-scm.com/) (cloning, pulling, committing, pushing) - How to run a [Python](https://www.python.org/) script -The script also shows you the ID of each bit of text you are translating, so that you can know where it is. `A.B` means string `B` in section `A`, `A.B.C` means string `C` in subsection `B` in section `A`, etc. +The script also shows you the ID of each bit of text you are translating, so that you can know where it is. `A.B` means string `B` in section `A`, `A.B.C` means string `C` in subsection `B` in section `A`, etc. -Clone the repository, then use the guided translation script (at `src/locales/guided_translation.py`) to update the translation files. You will need to pull before running, and commit/push your changes in order for them to be applied to CoinOS. +Clone the repository, then use the guided translation script (at `src/locales/guided_translation.py`) to update the translation files. You will need to pull before running, and commit/push your changes in order for them to be applied to CoinOS. diff --git a/src/components/About.svelte b/src/components/About.svelte index 3cd25f8c..55fc34d1 100644 --- a/src/components/About.svelte +++ b/src/components/About.svelte @@ -54,14 +54,16 @@ </div> </div> - <ul class="w-full mx-auto md:w-[700px] lg:w-[500px] xl:w-auto text-secondary px-1 md:px-10 text-xl list-disc space-y-5"> - <li>{$t('about.founder.qualifications.bitcoin')}</li> - <li>{$t('about.founder.qualifications.webDev')}</li> - <li>{$t('about.founder.qualifications.bitcoinVancouver')}</li> - <li>{$t('about.founder.qualifications.bitcoinCoop')}</li> - <li>{$t('about.founder.qualifications.beliefs')}</li> - <li>{$t('about.founder.qualifications.familialRelationships')}</li> - </ul> + <ul + class="w-full mx-auto md:w-[700px] lg:w-[500px] xl:w-auto text-secondary px-1 md:px-10 text-xl list-disc space-y-5" + > + <li>{$t('about.founder.qualifications.bitcoin')}</li> + <li>{$t('about.founder.qualifications.webDev')}</li> + <li>{$t('about.founder.qualifications.bitcoinVancouver')}</li> + <li>{$t('about.founder.qualifications.bitcoinCoop')}</li> + <li>{$t('about.founder.qualifications.beliefs')}</li> + <li>{$t('about.founder.qualifications.familialRelationships')}</li> + </ul> </div> <div class="mt-20"> diff --git a/src/lib/translations/index.js b/src/lib/translations/index.js index dc03c0b6..2b1f2481 100644 --- a/src/lib/translations/index.js +++ b/src/lib/translations/index.js @@ -3,42 +3,36 @@ import lang from './lang.json'; // setup loaders & translations from lang.json data function createLocaleLoader(localeCode) { - return { - locale: localeCode, - key: '', - loader: async () => ( - await import(`../../locales/${localeCode}.json`) - ).default - }; + return { + locale: localeCode, + key: '', + loader: async () => (await import(`../../locales/${localeCode}.json`)).default + }; } const availableLocales = Object.keys(lang); const translations = {}; for (let i = 0; i < availableLocales.length; i++) { - translations[availableLocales[i]] = { lang }; + translations[availableLocales[i]] = { lang }; } const loaders = availableLocales.map(createLocaleLoader); const config = { initLocale: 'en', - fallbackLocale: 'en', - translations: translations, - loaders: [ - { - locale: 'en', - key: '', - loader: async () => ( - await import("../../locales/en.json") - ).default - }, - { - locale: 'fr', - key: '', - loader: async () => ( - await import("../../locales/fr.json") - ).default - } - ] + fallbackLocale: 'en', + translations: translations, + loaders: [ + { + locale: 'en', + key: '', + loader: async () => (await import('../../locales/en.json')).default + }, + { + locale: 'fr', + key: '', + loader: async () => (await import('../../locales/fr.json')).default + } + ] }; export const { t, l, locales, locale } = new i18n(config); diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index 5eab20bd..3309393e 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -11,7 +11,7 @@ import { warning, protectedRoutes } from '$lib/utils'; import { t, locale } from '$lib/translations'; - const localeLocalStorageKey = 'sveltekit-i18n-locale'; + const localeLocalStorageKey = 'sveltekit-i18n-locale'; $: $token = data.token; @@ -21,7 +21,7 @@ $: $selectedRate = data.user && $rate * (data.rates[data.user.currency] / data.rates.USD); onMount(() => { - let localStorageLocale = localStorage.getItem(localeLocalStorageKey); + let localStorageLocale = localStorage.getItem(localeLocalStorageKey); if (localStorageLocale) locale.set(localStorageLocale); locale.subscribe((lng) => { diff --git a/src/routes/[username]/dashboard/+page.svelte b/src/routes/[username]/dashboard/+page.svelte index e4f6538e..969717df 100644 --- a/src/routes/[username]/dashboard/+page.svelte +++ b/src/routes/[username]/dashboard/+page.svelte @@ -110,19 +110,6 @@ : 'opacity-100'} rounded-2xl border py-3 font-bold w-full mt-2 bg-black text-white" on:click={withdraw}>{$t('user.dashboard.send')}</button > - - <div> - <label for="note" class="font-bold mb-1 block">{$t('user.dashboard.optionalNote')}</label> - <textarea name="note" rows={2} class="block rounded-2xl p-3 w-full bg-primary" /> - </div> - - <button - disabled={!payreq} - class="{!payreq - ? 'opacity-50' - : 'opacity-100'} rounded-2xl border py-3 font-bold w-full mt-2 bg-black text-white" - on:click={withdraw}>{$t('user.dashboard.send')}</button - > </div> {/if} </div> diff --git a/src/routes/invoice/+server.js b/src/routes/invoice/+server.js index 4b961be9..3942904b 100644 --- a/src/routes/invoice/+server.js +++ b/src/routes/invoice/+server.js @@ -10,7 +10,7 @@ export async function POST({ request }) { ({ text } = await post('/lightning/invoice', { amount }, headers)); let invoice = { amount, currency, network, rate, tip, text }; - let { uuid } = await post('/invoice', { invoice, user: { username } }, headers); + let { uuid } = await post('/invoice', { invoice, user: { username } }, headers); return new Response(JSON.stringify(uuid), { headers: { 'content-type': 'application/json' } }); } diff --git a/src/routes/invoice/[id]/+page.server.js b/src/routes/invoice/[id]/+page.server.js index d46d039b..5ab0069a 100644 --- a/src/routes/invoice/[id]/+page.server.js +++ b/src/routes/invoice/[id]/+page.server.js @@ -5,4 +5,3 @@ export async function load({ params }) { let { id } = params; return { id, invoice: await get(`/invoice?uuid=${id}`) }; } - |
