Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 11 additions & 0 deletions packages/timecop/lib/window-panel-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export default class WindowPanelView {
this.disposables.add(atom.tooltips.add(this.refs.windowTiming, {title: 'The time taken to load this window'}))
this.disposables.add(atom.tooltips.add(this.refs.projectTiming, {title: 'The time taken to rebuild the previously opened buffers'}))
this.disposables.add(atom.tooltips.add(this.refs.workspaceTiming, {title: 'The time taken to rebuild the previously opened editors'}))
this.disposables.add(atom.tooltips.add(this.refs.localeTiming, {title: 'The time taken to load core locales'}))
}

update () {}
Expand Down Expand Up @@ -49,6 +50,12 @@ export default class WindowPanelView {
<span className='inline-block' ref='workspaceLoadTime'>Loading…</span>
</div>
</div>

<div className='timing' ref='localeTiming'>
<span className='inline-block'>Locale load time</span>
<span className='inline-block' ref='localeLoadTime'>Loading…</span>
</div>

</div>
</div>
</div>
Expand Down Expand Up @@ -77,6 +84,10 @@ export default class WindowPanelView {
} else {
this.refs.deserializeTimings.style.display = 'none'
}

const localeLoadTime = atom.localeLoadTime;
this.refs.localeLoadTime.classList.add(this.getHighlightClass(localeLoadTime))
this.refs.localeLoadTime.textContent = `${localeLoadTime}ms`
}

getHighlightClass (time) {
Expand Down
2 changes: 2 additions & 0 deletions src/atom-environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,12 @@ class AtomEnvironment {
});

/** @type {I18n} */
const localeLoadStartTime = performance.now();
this.i18n = new I18n({
config: this.config
});
this.i18n.preload();
this.localeLoadTime = Math.round(performance.now() - localeLoadStartTime);

/** @type {KeymapManager} */
this.keymaps = new KeymapManager({
Expand Down
48 changes: 25 additions & 23 deletions src/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -534,35 +534,37 @@ module.exports = class Package {
}

loadLocales() {
if (this.bundledPackage && this.packageManager.packagesCache[this.name]) {
for (const localePath in this.packageManager.packagesCache[this.name].locales) {
const localeFilePathSplit = localePath.split(".");
const locale = localeFilePathSplit[localeFilePathSplit.length - 2] ?? "";
if (atom.i18n.shouldIncludeLocale(locale)) {
const localeFile = this.packageManager.packagesCache[this.name].locales[localePath];
const localeObj = {};
localeObj[this.name] = localeFile;
atom.i18n.addStrings(localeObj, locale);
}
}
} else {
const localesDirPath = path.join(this.path, "locales");
const localesPaths = fs.listSync(localesDirPath, ["cson", "json"]);

for (const localePath of localesPaths) {
const localeFilePath = localePath.split(".");
// `package-name.en-US.json` => `en-US`
const locale = localeFilePath[localeFilePath.length - 2] ?? "";
if (atom.i18n.shouldIncludeLocale(locale)) {
const localeFile = CSON.readFileSync(localePath);
if (localeFile) {
this.measure('loadTime:locales', () => {
if (this.bundledPackage && this.packageManager.packagesCache[this.name]) {
for (const localePath in this.packageManager.packagesCache[this.name].locales) {
const localeFilePathSplit = localePath.split(".");
const locale = localeFilePathSplit[localeFilePathSplit.length - 2] ?? "";
if (atom.i18n.shouldIncludeLocale(locale)) {
const localeFile = this.packageManager.packagesCache[this.name].locales[localePath];
const localeObj = {};
localeObj[this.name] = localeFile;
atom.i18n.addStrings(localeObj, locale);
}
}
} else {
const localesDirPath = path.join(this.path, "locales");
const localesPaths = fs.listSync(localesDirPath, ["cson", "json"]);

for (const localePath of localesPaths) {
const localeFilePath = localePath.split(".");
// `package-name.en-US.json` => `en-US`
const locale = localeFilePath[localeFilePath.length - 2] ?? "";
if (atom.i18n.shouldIncludeLocale(locale)) {
const localeFile = CSON.readFileSync(localePath);
if (localeFile) {
const localeObj = {};
localeObj[this.name] = localeFile;
atom.i18n.addStrings(localeObj, locale);
}
}
}
}
}
});
}

getKeymapPaths() {
Expand Down
Loading