mirror of
https://github.com/embarklabs/embark.git
synced 2025-01-11 14:24:24 +00:00
move i18n to core
This commit is contained in:
parent
3e6210c6d1
commit
61a8878e33
@ -1,6 +1,6 @@
|
|||||||
const program = require('commander');
|
const program = require('commander');
|
||||||
const Embark = require('../lib/index');
|
const Embark = require('../lib/index');
|
||||||
const i18n = require('./i18n/i18n.js');
|
const i18n = require('./core/i18n/i18n.js');
|
||||||
let embark = new Embark;
|
let embark = new Embark;
|
||||||
|
|
||||||
class Cmd {
|
class Cmd {
|
||||||
|
@ -8,7 +8,7 @@ i18n.configure({
|
|||||||
locales: supported_languages,
|
locales: supported_languages,
|
||||||
register: global,
|
register: global,
|
||||||
updateFiles: false,
|
updateFiles: false,
|
||||||
directory: path.join(__dirname, 'locales')
|
directory: path.join(__dirname, '../../../', 'locales')
|
||||||
});
|
});
|
||||||
|
|
||||||
function isSupported(locale) {
|
function isSupported(locale) {
|
@ -1,7 +1,8 @@
|
|||||||
const {PerformanceObserver, performance} = require('perf_hooks');
|
const {PerformanceObserver, performance} = require('perf_hooks');
|
||||||
require('colors');
|
require('colors');
|
||||||
const utils = require('../utils/utils.js');
|
const utils = require('../utils/utils.js');
|
||||||
const i18n = require('../i18n/i18n.js');
|
// TODO: remove this
|
||||||
|
const i18n = require('../../core/i18n/i18n.js');
|
||||||
i18n.setOrDetectLocale('en');
|
i18n.setOrDetectLocale('en');
|
||||||
|
|
||||||
|
|
||||||
@ -13,17 +14,15 @@ class NpmTimer{
|
|||||||
this._showSpinner = options.showSpinner || false;
|
this._showSpinner = options.showSpinner || false;
|
||||||
this._spinnerStyle = options.spinnerStyle || 'dots';
|
this._spinnerStyle = options.spinnerStyle || 'dots';
|
||||||
this._interval = options.interval || 750;
|
this._interval = options.interval || 750;
|
||||||
|
|
||||||
// define mark and measurement names
|
// define mark and measurement names
|
||||||
this._startMark = 'downloadStart' + this._packageName + this._version;
|
this._startMark = 'downloadStart' + this._packageName + this._version;
|
||||||
this._ongoingMark = 'downloadOngoingMark' + this._packageName + this._version;
|
this._ongoingMark = 'downloadOngoingMark' + this._packageName + this._version;
|
||||||
this._downloadOngoing = 'downloadOngoing' + this._packageName + this._version;
|
this._downloadOngoing = 'downloadOngoing' + this._packageName + this._version;
|
||||||
this._endMark = 'downloadEnd' + this._packageName + this._version;
|
this._endMark = 'downloadEnd' + this._packageName + this._version;
|
||||||
this._downloadComplete = 'downloadComplete' + this._packageName + this._version;
|
this._downloadComplete = 'downloadComplete' + this._packageName + this._version;
|
||||||
|
|
||||||
this.observer.observe({entryTypes: ['measure']});
|
|
||||||
|
|
||||||
|
this.observer.observe({entryTypes: ['measure']});
|
||||||
}
|
}
|
||||||
|
|
||||||
get observer(){
|
get observer(){
|
||||||
@ -31,7 +30,7 @@ class NpmTimer{
|
|||||||
this._observer = new PerformanceObserver((items) => {
|
this._observer = new PerformanceObserver((items) => {
|
||||||
let entry;
|
let entry;
|
||||||
let strDuration;
|
let strDuration;
|
||||||
|
|
||||||
// find any download ongoing measurements we've made
|
// find any download ongoing measurements we've made
|
||||||
entry = utils.last(items.getEntries().filter(entry => entry.name === this._downloadOngoing));
|
entry = utils.last(items.getEntries().filter(entry => entry.name === this._downloadOngoing));
|
||||||
if(entry){
|
if(entry){
|
||||||
@ -42,14 +41,13 @@ class NpmTimer{
|
|||||||
else{
|
else{
|
||||||
// otherwise, find our download complete measurement
|
// otherwise, find our download complete measurement
|
||||||
entry = utils.last(items.getEntries().filter(entry => entry.name === this._downloadComplete));
|
entry = utils.last(items.getEntries().filter(entry => entry.name === this._downloadComplete));
|
||||||
|
|
||||||
if(entry){
|
if(entry){
|
||||||
strDuration = __('Finished downloading and installing {{packageName}} {{version}} in {{duration}}ms', {packageName: this._packageName, version: this._version, duration: entry.duration});
|
strDuration = __('Finished downloading and installing {{packageName}} {{version}} in {{duration}}ms', {packageName: this._packageName, version: this._version, duration: entry.duration});
|
||||||
performance.clearMarks();
|
performance.clearMarks();
|
||||||
if(this._spinner) this._spinner.succeed(strDuration);
|
if(this._spinner) this._spinner.succeed(strDuration);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// log our measurement and make it red if it has taken too long
|
// log our measurement and make it red if it has taken too long
|
||||||
if(!this._showSpinner && entry && strDuration){
|
if(!this._showSpinner && entry && strDuration){
|
||||||
if(entry.duration > 4000){
|
if(entry.duration > 4000){
|
||||||
@ -57,12 +55,12 @@ class NpmTimer{
|
|||||||
}
|
}
|
||||||
this._logger.info(strDuration);
|
this._logger.info(strDuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return this._observer;
|
return this._observer;
|
||||||
}
|
}
|
||||||
|
|
||||||
start(){
|
start(){
|
||||||
let self = this;
|
let self = this;
|
||||||
|
|
||||||
@ -79,7 +77,7 @@ class NpmTimer{
|
|||||||
|
|
||||||
// mark our start time
|
// mark our start time
|
||||||
performance.mark(this._startMark);
|
performance.mark(this._startMark);
|
||||||
|
|
||||||
// function that continually updates the console to show user that we're downloading a library
|
// function that continually updates the console to show user that we're downloading a library
|
||||||
this._intOngoingDownload = setInterval(
|
this._intOngoingDownload = setInterval(
|
||||||
function(){
|
function(){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user