Skip to content
This repository has been archived by the owner on Jan 3, 2019. It is now read-only.

Localization #59

Merged
merged 25 commits into from
Aug 2, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
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
19 changes: 19 additions & 0 deletions app/lib/i18n/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
'use strict';

var translate = require('counterpart')
var fs = require('fs')

translate.setSeparator('*')

var translation = fs.readFileSync(__dirname + '/translations/' + process.env.LANGUAGE + '.json', {encoding: 'utf8'})
translate.registerTranslations(process.env.LANGUAGE, JSON.parse(translation))
translate.setLocale(process.env.LANGUAGE)

var languages = fs.readdirSync(__dirname + '/translations').map(function(f){
return f.replace('.json', '')
})

module.exports = {
translate: translate,
languages: languages
}
18 changes: 18 additions & 0 deletions app/lib/i18n/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "hive-i18n",
"version": "0.0.0",
"description": "",
"main": "index.js",
"author": "Wei Lu",
"license": "GPL-2.0+",
"dependencies": {
"brfs": "^1.2.0",
"counterpart": "^0.16.0"
},
"browserify": {
"transform": [
"envify",
"brfs"
]
}
}
100 changes: 100 additions & 0 deletions app/lib/i18n/translations/en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
{
"Back to": "Back to",
"Create new wallet": "Create new wallet",
"Open existing wallet": "Open existing wallet",
"We are about to generate your very own passphrase": "We're about to generate your very own passphrase",
"This keeps your account secure, and lets you open your wallet on multiple devices.": "This keeps your account secure, and lets you open your wallet on multiple devices.",
"It is very important you write this down.": "It's very important you write this down.",
"Generate passphrase": "Generate passphrase",
"Go back": "Go back",
"Generating": "Generating",
"Decoding seed phrase": "Decoding seed phrase",
"Synchronizing Wallet": "Synchronizing Wallet",
"Set your PIN": "Set your PIN",
"Your passphrase": "Your passphrase",
"Your passphrase will not be shown again.": "Your passphrase will not be shown again.",
"Without it you will lose access to your wallet.": "Without it you will lose access to your wallet.",
"I have written down or otherwise securely stored my passphrase": "I have written down or otherwise securely stored my passphrase",
"Open wallet": "Open wallet",
"Checking passphrase": "Checking passphrase",
"Enter Passphrase": "Enter Passphrase",
"Invalid passphrase": "Invalid passphrase",
"Enter your PIN": "Enter your PIN",
"Set a PIN for quick access": "Set a PIN for quick access",
"Review passphrase again": "Review passphrase again",
"Open a different wallet": "Open a different wallet",
"PIN must be a 4-digit number": "PIN must be a 4-digit number",
"Verifying PIN": "Verifying PIN",
"Setting PIN": "Setting PIN",
"This might take some time,": "This might take some time,",
"please be patient.": "please be patient.",
"Your PIN is incorrect": "Your PIN is incorrect",
"Request timeout. Please check your internet connection.": "Request timeout. Please check your internet connection.",
"Could not save your details": "Could not save your details",
"We could not connect you to Waggle, please check your internet connection.": "We couldn't connect you to Waggle, please check your internet connection.",
"Please enter a valid address to send to": "Please enter a valid address to send to",
"Please enter an amount above": "Please enter an amount above %(dust)s",
"Some funds are temporarily unavailable. To send this transaction, you will need to wait for your pending transactions to be confirmed first (this should not take more than a few minutes).": "Some funds are temporarily unavailable. To send this transaction, you'll need to wait for your pending transactions to be confirmed first (this shouldn't take more than a few minutes).",
"What does this mean?": "What does this mean?",
"It seems like you are trying to empty your wallet. Taking transaction fee into account, we estimated that the max amount you can send is. We have amended the value in the amount field for you": "It seems like you are trying to empty your wallet. Taking transaction fee into account, we estimated that the max amount you can send is %(sendableBalance)s. We have amended the value in the amount field for you.",
"You do not have enough funds in your wallet": "You don't have enough funds in your wallet",
"A name is required to set your profile on Hive": "A name is required to set your profile on Hive",
"Uh Oh...": "Uh Oh...",
"Whoops!": "Whoops!",
"Just saying...": "Just saying...",
"Your browser does not support geolocation": "Your browser does not support geolocation",
"Unable to retrieve your location": "Unable to retrieve your location",
"Without a name, the payer would not be able to identify you on waggle.": "Without a name, the payer wouldn't be able to identify you on waggle.",
"cannot be blank": "%(blankField)s cannot be blank",
"name": "name",
"email": "email",
"description": "description",
"Change your details": "Change your details",
"Your name": "Your name",
"Gravatar email": "Gravatar email",
"Submit": "Submit",
"Gravatar (globally recognised avatar) is a service that lets you re-use the same avatar across websites and apps by specifying an email address.": "Gravatar (globally recognised avatar) is a service that lets you re-use the same avatar across websites and apps by specifying an email address.",
"Create a gravatar": "Create a gravatar",
"Logout": "Logout",
"Support": "Support",
"Send": "Send",
"Receive": "Receive",
"History": "History",
"Tokens": "Tokens",
"Waggle lets you broadcast your wallet address to other nearby Hive users by comparing GPS data. This data is deleted once you turn Waggle off.": "Waggle lets you broadcast your wallet address to other nearby Hive users by comparing GPS data. This data is deleted once you turn Waggle off.",
"Having problems?": "Having problems?",
"Description": "Description",
"Your email address": "Your email address",
"Nevermind": "Nevermind",
"Before you start using Waggle, you need to enter a name that will help others identify you.": "Before you start using Waggle, you need to enter a name that will help others identify you.",
"Save": "Save",
"Your transaction history": "Your transaction history",
"pending confirmation": "pending confirmation",
"Received": "Received",
"You do not have any transactions yet": "You don't have any transactions yet",
"Transaction Id:": "Transaction Id:",
"Sent to:": "Sent to:",
"Your wallet address": "Your wallet address",
"Waggle": "Waggle",
"Turn Waggle on": "Turn Waggle on",
"Turn Waggle off": "Turn Waggle off",
"Checking your location": "Checking your location",
"Broadcasting your location...": "Broadcasting your location...",
"Wallet address": "Wallet address",
"Amount": "Amount",
"Exchange rate unavailable for the selected currency": "Exchange rate unavailable for the selected currency",
"Confirm": "Confirm",
"No Hive users found nearby": "No Hive users found nearby",
"Search Again": "Search Again",
"Searching your area for other Hive Web users": "Searching your area for other Hive Web users",
"Confirm transaction": "Confirm transaction",
"transaction fee": "transaction fee",
"Cancel": "Cancel",
"Transaction Successful": "Transaction Successful",
"Your transaction will appear in your history tab shortly.": "Your transaction will appear in your history tab shortly.",
"Close": "Close",
"Transaction Failed": "Transaction Failed",
"Please make sure you are connected to the internet.": "Please make sure you are connected to the internet.",
"Sorry, Hive Wallet did not load.": "Sorry, Hive Wallet didn't load.",
"Try updating your browser, or switching out of private browsing mode. If all else fails, download Chrome for your device.": "Try updating your browser, or switching out of private browsing mode. If all else fails, download Chrome for your device."
}
100 changes: 100 additions & 0 deletions app/lib/i18n/translations/zh-CN.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
{
"Back to": "返回",
"Create new wallet": "新建钱包",
"Open existing wallet": "打开钱包",
"We are about to generate your very own passphrase": "我们将为您生成您的钱包口令",
"This keeps your account secure, and lets you open your wallet on multiple devices.": "为保证您的帐户安全,并让您在多个设备上打开您的钱包,",
"It is very important you write this down.": "请您一定将口令写下来并安全保管。",
"Generate passphrase": "生成口令",
"Go back": "返回",
"Generating": "生成中……",
"Decoding seed phrase": "解码口令",
"Synchronizing Wallet": "同步钱包",
"Set your PIN": "设置您的PIN码",
"Your passphrase": "您的口令",
"Your passphrase will not be shown again.": "您的口令将不再显示。",
"Without it you will lose access to your wallet.": "如果口令丢失,您将无法访问您的钱包。",
"I have written down or otherwise securely stored my passphrase": "我已经将口令写下来或以其它方式安全的妥善存储",
"Open wallet": "打开钱包",
"Checking passphrase": "检查口令",
"Enter Passphrase": "输入口令",
"Invalid passphrase": "无效的口令",
"Enter your PIN": "输入PIN码",
"Set a PIN for quick access": "设置一个PIN码,以便快速访问",
"Review passphrase again": "复查口令",
"Open a different wallet": "打开一个不同的钱包",
"PIN must be a 4-digit number": "PIN码必须是4位数字",
"Verifying PIN": "验证PIN码",
"Setting PIN": "设置PIN码",
"This might take some time,": "这项操作可能需要一些时间,",
"please be patient.": "请耐心等候",
"Your PIN is incorrect": "您的PIN码不正确",
"Request timeout. Please check your internet connection.": "请求超时,请检查您的网络连接。",
"Could not save your details": "无法保存您的个人资料",
"We could not connect you to Waggle, please check your internet connection.": "我们无法连接到Waggle,请检查您的网络连接。",
"Please enter a valid address to send to": "请输入一个有效的地址",
"Please enter an amount above": "请输入金额高于%(dust)s",
"Some funds are temporarily unavailable. To send this transaction, you will need to wait for your pending transactions to be confirmed first (this should not take more than a few minutes).": "部分资金暂时不可用,发送款项后您需要等待比特币网络确认交易信息(通常需要几分钟)。",
"What does this mean?": "这是什么意思?",
"It seems like you are trying to empty your wallet. Taking transaction fee into account, we estimated that the max amount you can send is. We have amended the value in the amount field for you": "貌似您想要清空您的钱包。减去估算的交易手续费,我们已将金额修改为您可以发送的最大金额,请确认。",
"You do not have enough funds in your wallet": "您的钱包没有足够的资金",
"A name is required to set your profile on Hive": "姓名是必填项",
"Uh Oh...": "呃哦...",
"Whoops!": "哎呦!",
"Just saying...": "友情提醒:",
"Your browser does not support geolocation": "您的浏览器不支持地理定位",
"Unable to retrieve your location": "无法获取您的位置",
"Without a name, the payer would not be able to identify you on waggle.": "没有姓名,付款人将无法在Waggle上识别您的身份。",
"cannot be blank": "%(blankField)s不能为空",
"name": "姓名",
"email": "电子邮件",
"description": "说明",
"Change your details": "更新您的个人资料",
"Your name": "姓名",
"Gravatar email": "Gravatar对应的电子邮件",
"Submit": "提交",
"Gravatar (globally recognised avatar) is a service that lets you re-use the same avatar across websites and apps by specifying an email address.": "Gravatar(globally recognised avatar)是一个让您将头像和邮件地址关联的服务。",
"Create a gravatar": "创建一个gravatar账户",
"Logout": "退出",
"Support": "帮助",
"Send": "发送",
"Receive": "接收",
"History": "历史",
"Tokens": "币种",
"Waggle lets you broadcast your wallet address to other nearby Hive users by comparing GPS data. This data is deleted once you turn Waggle off.": "Waggle通过比较GPS数据广播您的钱包地址给附近的Hive用户。一旦您关闭Waggle该数据即会被删除。",
"Having problems?": "有问题吗?",
"Description": "说明",
"Your email address": "电子邮件地址",
"Nevermind": "算了",
"Before you start using Waggle, you need to enter a name that will help others identify you.": "Waggle需要您输入一个姓名,这将帮助别人识别你。",
"Save": "保存",
"Your transaction history": "您的交易记录",
"pending confirmation": "待确认",
"Received": "收到",
"You do not have any transactions yet": "您没有任何交易",
"Transaction Id:": "交易ID:",
"Sent to:": "发送到:",
"Your wallet address": "你的钱包地址",
"Waggle": "Waggle",
"Turn Waggle on": "打开Waggle",
"Turn Waggle off": "关闭Waggle",
"Checking your location": "确认你的位置",
"Broadcasting your location...": "广播您的位置......",
"Wallet address": "钱包地址",
"Amount": "金额",
"Exchange rate unavailable for the selected currency": "选择的货币当前没有汇率数据",
"Confirm": "确认",
"No Hive users found nearby": "附近没有Hive用户",
"Search Again": "重新搜索",
"Searching your area for other Hive Web users": "搜索您所在地区的其他Hive用户",
"Confirm transaction": "确认交易",
"transaction fee": "交易手续费",
"Cancel": "取消",
"Transaction Successful": "交易成功",
"Your transaction will appear in your history tab shortly.": "您的交易不久将出现在您的历史记录页面。",
"Close": "关闭",
"Transaction Failed": "交易失败",
"Please make sure you are connected to the internet.": "请确认您已连接到互联网。",
"Sorry, Hive Wallet did not load.": "对不起,Hive钱包加载失败。",
"Try updating your browser, or switching out of private browsing mode. If all else fails, download Chrome for your device.": "尝试更新您的浏览器,或退出匿名浏览模式。如果仍然不能加载,请下载Chrome浏览器。"
}
3 changes: 3 additions & 0 deletions app/lib/ractive/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict';
var Ractive = require('ractive/build/ractive.runtime')
var translate = require('hive-i18n').translate

// extracted from https://github.com/RactiveJS/Ractive-events-keys
var makeKeyDefinition = function ( code ) {
Expand Down Expand Up @@ -81,4 +82,6 @@ Ractive.prototype.show = function(){
this.el.classList.add('current')
}

Ractive.data = { translate: translate }

module.exports = Ractive
2 changes: 1 addition & 1 deletion app/lib/third-party-api/blockr.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function Blockr(network){

function listAddresses(addresses, onAddresses){
if(!addresses || !addresses.length) {
var error = new Error("Addresses can't be blank")
var error = new Error("Addresses cannot be blank")
return onAddresses(error)
}

Expand Down
2 changes: 1 addition & 1 deletion app/lib/wallet/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ function nextReceiveAddress() {
}

function createWallet(passphrase, network, callback) {
var message = passphrase ? 'Decoding seed phrase' : 'Generating...'
var message = passphrase ? 'Decoding seed phrase' : 'Generating'
emitter.emit('wallet-opening', message)

var data = {passphrase: passphrase}
Expand Down
18 changes: 10 additions & 8 deletions app/lib/wallet/validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ function validateSend(wallet, to, btcValue, callback){
var message = e.message

if(message.match(/dust threshold/)) {
message = 'Please enter an amount above ' + satoshiToBtc(network.dustThreshold)
message = 'Please enter an amount above'
error = new Error(message)
error.interpolations = { dust: satoshiToBtc(network.dustThreshold) }
return new callback(error)
} else if(message.match(/Not enough funds/)) {
var hasAndNeeded = getHasAndNeeded(message)
var has = hasAndNeeded[0]
Expand All @@ -30,26 +33,25 @@ function validateSend(wallet, to, btcValue, callback){
var error

if(sufficientWithPending(needed) || (spendAll && hasPendingUtxo())){
error = new Error("Some funds are temporarily unavailable. To send this transaction, you'll need to wait for your pending transactions to be confirmed first (this shouldn't take more than a few minutes).")
error = new Error("Some funds are temporarily unavailable. To send this transaction, you will need to wait for your pending transactions to be confirmed first (this should not take more than a few minutes).")
error.href = "https://github.com/hivewallet/hive-osx/wiki/Sending-Bitcoin-from-a-pending-transaction"
error.linkText = "What does this mean?"
return callback(error)
} else if(spendAll){
var sendableBalance = satoshiToBtc(amount - (needed - has))

message = [
"It seems like you are trying to empty your wallet.",
"It seems like you are trying to empty your wallet",
"Taking transaction fee into account, we estimated that the max amount you can send is",
sendableBalance + ".",
"We have amended the value in the amount field for you."
].join(' ')
"We have amended the value in the amount field for you"
].join('. ')

error = new Error(message)
error.sendableBalance = sendableBalance
error.interpolations = { sendableBalance: sendableBalance }

return new callback(error)
} else {
message = "You don't have enough funds in your wallet"
message = "You do not have enough funds in your wallet"
}
}

Expand Down
14 changes: 12 additions & 2 deletions app/loader/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

require('browsernizr/lib/load')
require('browsernizr/test/storage/localstorage')
require('browsernizr/test/storage/websqldatabase')
Expand All @@ -10,6 +12,7 @@ var token = require('hive-network')()
var animateLogo = require('hive-transitions/loader.js').in
var fadeOut = require('hive-transitions/loader.js').out
var Modernizr = require('browsernizr')
var languages = require('hive-i18n').languages

document.getElementsByTagName('html')[0].classList.add(token)

Expand All @@ -29,11 +32,12 @@ animateLogo(elems)

Modernizr.on('indexeddb', function(hasIndexedDB){
var supportsPouchDB = hasIndexedDB || Modernizr.websqldatabase
var language = findTranslation()

Modernizr.load({
test: supportsPouchDB && (Modernizr.localstorage && Modernizr.webworkers && Modernizr.blobconstructor && Modernizr.getrandomvalues),
yep: 'assets/js/application.js',
nope: 'assets/js/nope.js',
yep: 'assets/js/application-' + language + '.js',
nope: 'assets/js/nope-' + language + '.js',
callback: function(testResult, key) {
goodToGo = key
},
Expand All @@ -47,6 +51,12 @@ Modernizr.on('indexeddb', function(hasIndexedDB){
})
})

function findTranslation(){
var language = navigator.language.toLocaleLowerCase() || 'en'
return languages.filter(function(l){
return language === l || language.substr(0, 2) === l
})[0]
}

//monkey patch URL for safari 6
window.URL = window.URL || window.webkitURL
Expand Down
8 changes: 7 additions & 1 deletion app/loader/nope.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
var message = "Sorry, Hive Wallet didn't load. <br/><br/> Try updating your browser, or switching out of private browsing mode. If all else fails, download Chrome for your device."
'use strict';
var translate = require('hive-i18n').translate

var message = translate("Sorry, Hive Wallet did not load.") +
"<br/><br/>" +
translate("Try updating your browser, or switching out of private browsing mode. If all else fails, download Chrome for your device.")

document.getElementById('loader-message').innerHTML = message
11 changes: 11 additions & 0 deletions app/loader/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "hive-loader",
"version": "0.0.0",
"description": "",
"main": "index.js",
"author": "Wei Lu",
"license": "GPL-2.0+",
"browserify": {
"transform": [ "envify" ]
}
}
Loading