Get jdsoc tagging right for util module

This commit is contained in:
Nick O'Leary
2018-08-28 13:45:38 +01:00
parent 79e004a040
commit 19c9707d62
4 changed files with 110 additions and 25 deletions

View File

@@ -15,6 +15,11 @@
* @ignore
**/
/**
* @module i18n
* @memberof module:@node-red/util
*/
var i18n = require("i18next");
var when = require("when");
@@ -27,6 +32,10 @@ var resourceMap = {};
var resourceCache = {};
var initPromise;
/**
* Register multiple message catalogs with i18n.
* @memberof module:@node-red/util.module:i18n
*/
function registerMessageCatalogs(catalogs) {
var promises = catalogs.map(function(catalog) {
return registerMessageCatalog(catalog.namespace,catalog.dir,catalog.file);
@@ -34,6 +43,10 @@ function registerMessageCatalogs(catalogs) {
return when.settle(promises);
}
/**
* Register a message catalog with i18n.
* @memberof module:@node-red/util.module:i18n
*/
function registerMessageCatalog(namespace,dir,file) {
return initPromise.then(function() {
return new Promise((resolve,reject) => {
@@ -128,6 +141,13 @@ function init() {
}
}
/**
* Gets a message catalog.
* @name catalog
* @function
* @memberof module:@node-red/util.module:i18n
*/
function getCatalog(namespace,lang) {
var result = null;
lang = lang || defaultLang;
@@ -148,10 +168,22 @@ var obj = module.exports = {
registerMessageCatalog: registerMessageCatalog,
registerMessageCatalogs: registerMessageCatalogs,
catalog: getCatalog,
/**
* The underlying i18n library for when direct access is really needed
*/
i: i18n,
/**
* The default language of the runtime
*/
defaultLang: defaultLang
}
/**
* Perform a message catalog lookup.
* @name _
* @function
* @memberof module:@node-red/util.module:i18n
*/
obj['_'] = function() {
//var opts = {};
//if (def) {