Skip to content

Commit

Permalink
i18n Modal Fixes (#254)
Browse files Browse the repository at this point in the history
* Fix Seed Phrase creation modal

* Fix "Create New Wallet" not translating

* Fix "Encrypt/Change Pass" modal not translating

* Fix negotiateLanguages typo

* Fix "Lang Parent" fallback if parent doesn't exist

* Prettier
  • Loading branch information
JSKitty committed Nov 9, 2023
1 parent 6a9ea66 commit abdb8fd
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 63 deletions.
35 changes: 0 additions & 35 deletions index.template.html
Expand Up @@ -133,41 +133,6 @@ <h5 data-i18n="balanceBreakdown" class="modal-title" id="walletBreakdownModalLab
</div>
</div>

<br />
<!-- // MNEMONIC MODAL -->
<div class="modal fade" id="mnemonicModal" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static" data-keyboard="false">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-body center-text">
<p id="ModalMnemonicLabel" class="modal-label"></p>
<div id="ModalMnemonic" class="auto-fit">
<span data-i18n="thisIsYourSeed">This is your seed phrase:</span>
<b>
<div translate="no" class="seed-phrase noselect notranslate" id="ModalMnemonicContent">
</div>
</b>
<br />
<span data-i18n="writeDownSeed">Write it down somewhere. You'll only see this <b>once!</b></span>
<br />
<span data-i18n="doNotShareWarning">Anyone with a copy of it can access <b>all</b> of your funds.</span>
<br />
<b data-i18n="doNotShare">Do NOT share it with anybody.</b> <br />
<br />
<a href="https://www.ledger.com/blog/how-to-protect-your-seed-phrase" target="_blank" rel="noopener noreferrer">
<i data-i18n="digitalStoreNotAdvised">It is <b>NOT</b> advised to store this digitally.</i>
</a>
<br />
<br />
<input data-i18n="optionalPassphrase" class="center-text" type="password" id="ModalMnemonicPassphrase" placeholder="Optional Passphrase" />
<br />
</div>
<div class="modal-footer">
<button type="button" data-i18n="writtenDown" id="modalMnemonicConfirmButton" class="pivx-button-big">I have written down my seed phrase</button>
</div>
</div>
</div>
</div>
</div>
<br />
<!-- // CONFIRM MODAL -->
<div class="modal" id="confirmModal" tabindex="-1" style="z-index: 2000; background-color: #00000063;" role="dialog" aria-hidden="true" data-backdrop="static" data-keyboard="false">
Expand Down
30 changes: 9 additions & 21 deletions scripts/dashboard/CreateWallet.vue
Expand Up @@ -51,9 +51,9 @@ async function generateWallet() {

<button class="pivx-button-big" @click="generateWallet()">
<span class="buttoni-icon" v-html="pLogo"> </span>
<span class="buttoni-text" data-i18n="dCardOneButton"
>Create A New Wallet</span
>
<span class="buttoni-text">
{{ translation.dCardOneButton }}
</span>
</button>
</div>
</div>
Expand All @@ -62,9 +62,7 @@ async function generateWallet() {
<template #body>
<p class="modal-label"></p>
<div class="auto-fit">
<span data-i18n="thisIsYourSeed"
>This is your seed phrase:</span
>
<span v-html="translation.thisIsYourSeed"></span>
<b>
<div
translate="no"
Expand All @@ -74,28 +72,19 @@ async function generateWallet() {
</div>
</b>
<br />
<span data-i18n="writeDownSeed"
>Write it down somewhere. You'll only see this
<b>once!</b></span
>
<span v-html="translation.writeDownSeed"></span>
<br />
<span data-i18n="doNotShareWarning"
>Anyone with a copy of it can access <b>all</b> of your
funds.</span
>
<span v-html="translation.doNotShareWarning"> </span>
<br />
<b data-i18n="doNotShare">Do NOT share it with anybody.</b>
<b> {{ translation.doNotShare }} </b>
<br />
<br />
<a
href="https://www.ledger.com/blog/how-to-protect-your-seed-phrase"
target="_blank"
rel="noopener noreferrer"
>
<i data-i18n="digitalStoreNotAdvised"
>It is <b>NOT</b> advised to store this
digitally.</i
>
<i v-html="translation.digitalStoreNotAdvised"></i>
</a>
<br />
<div v-if="fAdvancedMode">
Expand All @@ -113,11 +102,10 @@ async function generateWallet() {
<center>
<button
type="button"
data-i18n="writtenDown"
class="pivx-button-big"
@click="showModal = false"
>
I have written down my seed phrase
{{ translation.writtenDown }}
</button>
</center>
</template>
Expand Down
10 changes: 5 additions & 5 deletions scripts/dashboard/GenKeyWarning.vue
Expand Up @@ -84,7 +84,7 @@ function submit() {
modalClass="exportKeysModalColor"
>
<template #header>
<h5 class="modal-title">Encrypt wallet</h5>
<h5 class="modal-title">{{ translation.encryptWallet }}</h5>
<button
type="button"
class="close"
Expand All @@ -102,7 +102,7 @@ function submit() {
v-model="currentPassword"
style="width: 100%; font-family: monospace"
type="password"
placeholder="Current Password"
:placeholder="translation.encryptPasswordCurrent"
v-show="isEncrypt"
/>
<div class="col-12 col-md-6 p-0 pr-0 pr-md-1">
Expand All @@ -112,7 +112,7 @@ function submit() {
data-i18n="encryptPasswordFirst"
style="width: 100%; font-family: monospace"
type="password"
placeholder="Enter Password"
:placeholder="translation.encryptPasswordFirst"
/>
</div>
<div class="col-12 col-md-6 p-0 pl-0 pl-md-1">
Expand All @@ -122,7 +122,7 @@ function submit() {
data-i18n="encryptPasswordSecond"
style="width: 100%; font-family: monospace"
type="password"
placeholder="Re-enter Password"
:placeholder="translation.encryptPasswordSecond"
/>
</div>
</div>
Expand All @@ -139,7 +139,7 @@ function submit() {
></path>
</svg>
</span>
<span data-i18n="encrypt">Encrypt</span>
<span data-i18n="encrypt"> {{ translation.encrypt }} </span>
</button>
</template>
</Modal>
Expand Down
12 changes: 10 additions & 2 deletions scripts/i18n.js
Expand Up @@ -27,7 +27,15 @@ const defaultLang = 'en';
* @returns the 'parent' language of a langcode
*/
function getParentLanguage(langName) {
return langName.includes('-') ? langName.split('-')[0] : defaultLang;
const strParentCode = langName.includes('-')
? langName.split('-')[0]
: defaultLang;
// Ensure the code exists
if (arrActiveLangs.find((lang) => lang.code === strParentCode)) {
return strParentCode;
} else {
return defaultLang;
}
}

/**
Expand Down Expand Up @@ -100,7 +108,7 @@ export async function switchTranslation(langName) {
window.navigator.languages,
arrActiveLangs.slice(1).map((l) => l.code),
{
defualtLocale: defaultLang,
defaultLocale: defaultLang,
}
)[0];
}
Expand Down

0 comments on commit abdb8fd

Please sign in to comment.