From 7daf92f37fd3d8fe29635f1ac1682b555ae4219a Mon Sep 17 00:00:00 2001 From: rolong Date: Wed, 21 Mar 2018 19:56:20 +0800 Subject: [PATCH] Support importing Mnemonic Phrase in multiple languages --- app/scripts/controllers/decryptWalletCtrl.js | 28 ++++++++++++++++++- app/scripts/controllers/tabsCtrl.js | 8 ++++++ app/scripts/directives/walletDecryptDrtv.html | 17 +++++++++++ package.json | 2 +- 4 files changed, 53 insertions(+), 2 deletions(-) diff --git a/app/scripts/controllers/decryptWalletCtrl.js b/app/scripts/controllers/decryptWalletCtrl.js index 344e3c1c87..1878511297 100644 --- a/app/scripts/controllers/decryptWalletCtrl.js +++ b/app/scripts/controllers/decryptWalletCtrl.js @@ -164,7 +164,33 @@ var decryptWalletCtrl = function($scope, $sce, walletService) { }; $scope.onMnemonicChange = function() { $scope.showAOnly = false; - $scope.showMDecrypt = hd.bip39.validateMnemonic($scope.manualmnemonic); + var lang = hd.bip39.wordlists.english; + switch(globalFuncs.curMnemonicLang){ + case 'zhcn': + lang = hd.bip39.wordlists.chinese_simplified; + break + case 'zhtw': + lang = hd.bip39.wordlists.chinese_traditional; + break + case 'ja': + lang = hd.bip39.wordlists.japanese; + break + case 'ko': + lang = hd.bip39.wordlists.korean; + break + case 'es': + lang = hd.bip39.wordlists.spanish; + break + case 'it': + lang = hd.bip39.wordlists.italian; + break + case 'fr': + lang = hd.bip39.wordlists.french; + break + default: + break + } + $scope.showMDecrypt = hd.bip39.validateMnemonic($scope.manualmnemonic, lang); }; $scope.onParityPhraseChange = function() { if ($scope.parityPhrase) $scope.showParityDecrypt = true; diff --git a/app/scripts/controllers/tabsCtrl.js b/app/scripts/controllers/tabsCtrl.js index 3dda789d3d..ece5ccdc14 100644 --- a/app/scripts/controllers/tabsCtrl.js +++ b/app/scripts/controllers/tabsCtrl.js @@ -3,6 +3,7 @@ var tabsCtrl = function($scope, globalService, $translate, $sce) { $scope.gService = globalService; $scope.tabNames = $scope.gService.tabs; $scope.curLang = 'English'; + $scope.curMnemonicLang = 'English'; $scope.customNodeModal = document.getElementById('customNodeModal') ? new Modal(document.getElementById('customNodeModal')) : null; $scope.Validator = Validator; $scope.nodeList = nodes.nodeList; @@ -257,6 +258,13 @@ var tabsCtrl = function($scope, globalService, $translate, $sce) { } } + $scope.changeMnemonic = function(key,value) { + $scope.curMnemonicLang = value; + $scope.dropdownMnemonic = false; + globalFuncs.curMnemonicLang = key; + $scope.onMnemonicChange(); + } + $scope.changeLanguage = function(key, value) { $translate.use(key); $scope.setErrorMsgLanguage(); diff --git a/app/scripts/directives/walletDecryptDrtv.html b/app/scripts/directives/walletDecryptDrtv.html index c1454a351d..1bbef51b14 100644 --- a/app/scripts/directives/walletDecryptDrtv.html +++ b/app/scripts/directives/walletDecryptDrtv.html @@ -547,6 +547,23 @@
If you must, please double-check the URL & SSL cert. It should say https://www.myetherwallet.com & MYETHERWALLET LLC in your URL bar.
+