Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@jupyterlite/translation

Package Overview
Dependencies
Maintainers
1
Versions
75
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jupyterlite/translation - npm Package Compare versions

Comparing version 0.1.0-alpha.9 to 0.1.0-alpha.10

1

lib/translation.d.ts

@@ -12,2 +12,3 @@ import { JSONObject } from '@lumino/coreutils';

get(locale: string): Promise<JSONObject>;
private _prevLocale;
}
import { PageConfig, URLExt } from '@jupyterlab/coreutils';
/**
* A fake locale to retrieve all the language packs.
*/
const ALL = 'all';
/**
* A class to handle requests to /api/translations
*/
export class Translation {
constructor() {
this._prevLocale = '';
}
/**

@@ -13,6 +20,34 @@ * Get the translation data for the given locale

const apiURL = URLExt.join(PageConfig.getBaseUrl(), `api/translations/${locale}.json`);
const response = await fetch(apiURL);
const json = JSON.parse(await response.text());
return json;
try {
const response = await fetch(apiURL);
const json = JSON.parse(await response.text());
if (this._prevLocale !== ALL && locale === ALL) {
// TODO: fix this logic upstream?
// the upstream translation plugin relies on the comparison between
// the display name and the native name to enable or disable the commands:
// https://github.com/jupyterlab/jupyterlab/blob/befa831ffef36321b87f352a48fbe2439df6c872/packages/translation-extension/src/index.ts#L117
const prev = this._prevLocale;
json.data[prev].displayName = json.data[prev].nativeName;
if (prev !== 'en') {
json.data['en'].displayName = `${json.data['en'].nativeName} (default)`;
}
}
this._prevLocale = locale;
return json;
}
catch (e) {
if (locale) {
return {
data: {},
message: `Language pack '${locale}' not installed!`
};
}
return {
data: {
en: { displayName: 'English', nativeName: 'English' }
},
message: ''
};
}
}
}

2

package.json
{
"name": "@jupyterlite/translation",
"version": "0.1.0-alpha.9",
"version": "0.1.0-alpha.10",
"description": "JupyterLite - Translation",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/jupyterlite/jupyterlite",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc