Skip to content
This repository has been archived by the owner on Sep 5, 2020. It is now read-only.

Commit

Permalink
[i18n] add missing meteor package 'numeral:languages' (#1783)
Browse files Browse the repository at this point in the history
* [i18n] add missing meteor package 'numeral:languages'

* add better error message
  • Loading branch information
luclu authored and evertonfraga committed Mar 27, 2017
1 parent 30a9b3a commit 5d3b371
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 28 deletions.
3 changes: 2 additions & 1 deletion interface/.meteor/packages
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ frozeman:template-var
frozeman:reactive-timer
frozeman:storage
frozeman:global-notifications
numeral:numeral
[email protected]
sacha:spin
chuangbo:cookie
Expand Down Expand Up @@ -43,3 +42,5 @@ [email protected]
tap:i18n-bundler
shell-server
ecmascript
numeral:numeral
numeral:languages
1 change: 1 addition & 0 deletions interface/.meteor/versions
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ [email protected]
[email protected]
mrt:[email protected]
[email protected]_2
numeral:[email protected]
numeral:[email protected]_1
[email protected]
[email protected]
Expand Down
55 changes: 31 additions & 24 deletions interface/client/appStart.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ The init function of Mist
@method mistInit
*/
mistInit = function(){
mistInit = function () {
console.info('Initialise Mist Interface');

EthBlocks.init();

Tabs.onceSynced.then(function() {
if (0 <= location.search.indexOf('reset-tabs')) {
Tabs.onceSynced.then(function () {
if (location.search.indexOf('reset-tabs') >= 0) {
console.info('Resetting UI tabs');

Tabs.remove({});
}

if(!Tabs.findOne('browser')) {
if (!Tabs.findOne('browser')) {
console.debug('Insert tabs');

Tabs.insert({
Expand All @@ -27,58 +27,65 @@ mistInit = function(){
}

// overwrite wallet on start again, but use $set to dont remove titles
Tabs.upsert({_id: 'wallet'}, {$set: {
url: 'https://wallet.ethereum.org',
redirect: 'https://wallet.ethereum.org',
position: 1,
permissions: {
admin: true
Tabs.upsert(
{ _id: 'wallet' },
{
$set: {
url: 'https://wallet.ethereum.org',
redirect: 'https://wallet.ethereum.org',
position: 1,
permissions: {
admin: true
}
}
}
});
});

// Sets browser as default tab if:
// 1) there's no record of selected tab
// 2) data is corrupted (no saved tab matches localstore)
if(!LocalStore.get('selectedTab') || !Tabs.findOne(LocalStore.get('selectedTab'))){
if (!LocalStore.get('selectedTab') || !Tabs.findOne(LocalStore.get('selectedTab'))) {
LocalStore.set('selectedTab', 'wallet');
}
});
};


Meteor.startup(function(){
Meteor.startup(function () {
console.info('Meteor starting up...');

if (!location.hash) {
if (!location.hash) { // Main window
EthAccounts.init();
mistInit();
}

console.debug('Setting language');

// SET default language
if(Cookie.get('TAPi18next')) {
if (Cookie.get('TAPi18next')) {
TAPi18n.setLanguage(Cookie.get('TAPi18next'));
} else {
var userLang = navigator.language || navigator.userLanguage,
availLang = TAPi18n.getLanguages();
const userLang = navigator.language || navigator.userLanguage;
const availLang = TAPi18n.getLanguages();

// set default language
if (_.isObject(availLang) && availLang[userLang]) {
TAPi18n.setLanguage(userLang);
} else if (_.isObject(availLang) && availLang[userLang.substr(0,2)]) {
TAPi18n.setLanguage(userLang.substr(0,2));
} else if (_.isObject(availLang) && availLang[userLang.substr(0, 2)]) {
TAPi18n.setLanguage(userLang.substr(0, 2));
} else {
TAPi18n.setLanguage('en');
}
}
// change moment and numeral language, when language changes
Tracker.autorun(function(){
if(_.isString(TAPi18n.getLanguage())) {
var lang = TAPi18n.getLanguage().substr(0,2);
Tracker.autorun(function () {
if (_.isString(TAPi18n.getLanguage())) {
const lang = TAPi18n.getLanguage().substr(0, 2);
moment.locale(lang);
numeral.language(lang);
try {
numeral.language(lang);
} catch (err) {
console.error(`numeral.js couldn't set number formating: ${err.message}`);
}
EthTools.setLocale(lang);
}
});
Expand Down
8 changes: 5 additions & 3 deletions interface/project-tap.i18n
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"cdn_path" : "i18n",
"helper_name": "i18n",
"supported_languages": ["de", "en", "es", "fa", "fr", "it", "ja", "ko", "nb", "nl", "pt", "ru", "sq", "zh", "zh-TW"]
"cdn_path": "i18n",
"helper_name": "i18n",
"supported_languages": [
"de", "en", "es", "fa", "fr", "it", "ja", "ko", "nb", "nl", "pt", "ru", "sq", "zh", "zh-TW"
]
}

0 comments on commit 5d3b371

Please sign in to comment.