@jupyterlab/translation
Advanced tools
Comparing version 3.0.0-beta.3 to 3.0.0-beta.4
@@ -69,2 +69,6 @@ /** | ||
/** | ||
* The string prefix to add to localized strings. | ||
*/ | ||
stringsPrefix?: string; | ||
/** | ||
* Plural form function. | ||
@@ -116,2 +120,14 @@ */ | ||
/** | ||
* Set current strings prefix. | ||
* | ||
* @param prefix - The string prefix to set. | ||
*/ | ||
setStringsPrefix(prefix: string): void; | ||
/** | ||
* Get current strings prefix. | ||
* | ||
* @return The strings prefix. | ||
*/ | ||
getStringsPrefix(): string; | ||
/** | ||
* `sprintf` equivalent, takes a string and some arguments to make a | ||
@@ -298,2 +314,3 @@ * computed string. | ||
private setMessages; | ||
private _stringsPrefix; | ||
private _pluralForms; | ||
@@ -300,0 +317,0 @@ private _dictionary; |
@@ -28,3 +28,4 @@ /* ---------------------------------------------------------------------------- | ||
}, | ||
contextDelimiter: String.fromCharCode(4) // \u0004 | ||
contextDelimiter: String.fromCharCode(4), | ||
stringsPrefix: '' | ||
}; | ||
@@ -36,2 +37,3 @@ // Ensure the correct separator is used | ||
options.contextDelimiter || this._defaults.contextDelimiter; | ||
this._stringsPrefix = options.stringsPrefix || this._defaults.stringsPrefix; | ||
this._pluralFuncs = {}; | ||
@@ -97,2 +99,18 @@ this._dictionary = {}; | ||
/** | ||
* Set current strings prefix. | ||
* | ||
* @param prefix - The string prefix to set. | ||
*/ | ||
setStringsPrefix(prefix) { | ||
this._stringsPrefix = prefix; | ||
} | ||
/** | ||
* Get current strings prefix. | ||
* | ||
* @return The strings prefix. | ||
*/ | ||
getStringsPrefix() { | ||
return this._stringsPrefix; | ||
} | ||
/** | ||
* `sprintf` equivalent, takes a string and some arguments to make a | ||
@@ -382,3 +400,4 @@ * computed string. | ||
if (!options.pluralForm) | ||
return Gettext.strfmt(this.removeContext(messages[0]), ...args); | ||
return (this._stringsPrefix + | ||
Gettext.strfmt(this.removeContext(messages[0]), ...args)); | ||
let plural; | ||
@@ -403,3 +422,4 @@ // if a plural func is given, use that one | ||
plural.plural = 0; | ||
return Gettext.strfmt(this.removeContext(messages[plural.plural]), ...[n].concat(args)); | ||
return (this._stringsPrefix + | ||
Gettext.strfmt(this.removeContext(messages[plural.plural]), ...[n].concat(args))); | ||
} | ||
@@ -406,0 +426,0 @@ /** |
@@ -6,3 +6,3 @@ import { ITranslator, TranslationBundle } from './tokens'; | ||
export declare class TranslationManager implements ITranslator { | ||
constructor(); | ||
constructor(stringsPrefix?: string); | ||
/** | ||
@@ -25,3 +25,4 @@ * Fetch the localization data from the server. | ||
private _languageData; | ||
private _stringsPrefix; | ||
private _translationBundles; | ||
} |
@@ -9,7 +9,8 @@ // Copyright (c) Jupyter Development Team. | ||
export class TranslationManager { | ||
constructor() { | ||
constructor(stringsPrefix) { | ||
this._domainData = {}; | ||
this._englishBundle = new Gettext(); | ||
this._translationBundles = {}; | ||
this._connector = new TranslatorConnector(); | ||
this._stringsPrefix = stringsPrefix || ''; | ||
this._englishBundle = new Gettext({ stringsPrefix: this._stringsPrefix }); | ||
} | ||
@@ -45,3 +46,4 @@ /** | ||
domain: domain, | ||
locale: this._currentLocale | ||
locale: this._currentLocale, | ||
stringsPrefix: this._stringsPrefix | ||
}); | ||
@@ -48,0 +50,0 @@ if (domain in this._domainData) { |
{ | ||
"name": "@jupyterlab/translation", | ||
"version": "3.0.0-beta.3", | ||
"version": "3.0.0-beta.4", | ||
"description": "JupyterLab - Translation services", | ||
@@ -49,9 +49,9 @@ "keywords": [ | ||
"dependencies": { | ||
"@jupyterlab/coreutils": "^5.0.0-beta.3", | ||
"@jupyterlab/services": "^6.0.0-beta.3", | ||
"@jupyterlab/statedb": "^3.0.0-beta.3", | ||
"@jupyterlab/coreutils": "^5.0.0-beta.4", | ||
"@jupyterlab/services": "^6.0.0-beta.4", | ||
"@jupyterlab/statedb": "^3.0.0-beta.4", | ||
"@lumino/coreutils": "^1.5.3" | ||
}, | ||
"devDependencies": { | ||
"@jupyterlab/testutils": "^3.0.0-beta.3", | ||
"@jupyterlab/testutils": "^3.0.0-beta.4", | ||
"@types/jest": "^26.0.10", | ||
@@ -68,3 +68,3 @@ "@typescript-eslint/eslint-plugin": "^3.10.1", | ||
}, | ||
"gitHead": "2fb1e9c07c02f0f49066dcd6e5f402d352acfb79" | ||
"gitHead": "9b674667bda9fd5d4a05f3e7cc5bcb0433241b71" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
53843
1030