adjusted authorship

This commit is contained in:
Christian Fraß 2020-04-04 14:33:48 +02:00
parent 5ce78cc262
commit f93c042adc
3 changed files with 24 additions and 24 deletions

View file

@ -3,7 +3,7 @@ export /*abstract */class Cache {
/**
* @param {string} key
* @return {boolean}
* @author fenris
* @author svartoyg
*/
/*protected */has(key) {
throw (new Error('not implemented'));
@ -12,7 +12,7 @@ export /*abstract */class Cache {
/**
* @param {string} key
* @return {any}
* @author fenris
* @author svartoyg
*/
/*protected */fetch(key) {
throw (new Error('not implemented'));
@ -21,7 +21,7 @@ export /*abstract */class Cache {
/**
* @param {string} key
* @param {any} value
* @author fenris
* @author svartoyg
*/
/*protected */store(key, value) {
throw (new Error('not implemented'));
@ -31,7 +31,7 @@ export /*abstract */class Cache {
* @param {string} key
* @param {()=>Promise<any>} retrieve
* @return {Promise<any>}
* @author fenris
* @author svartoyg
*/
/*public */async get(key, retrieve) {
if (this.has(key)) {
@ -47,32 +47,32 @@ export /*abstract */class Cache {
/**
* @author fenris
* @author svartoyg
*/
class CacheNone extends Cache {
/**
* @author fenris
* @author svartoyg
*/
/*public */constructor() {
super();
}
/**
* @author fenris
* @author svartoyg
*/
/*protected */has(key) {
return false;
}
/**
* @author fenris
* @author svartoyg
*/
/*protected */fetch(key) {
throw (new Error('not possible'));
}
/**
* @author fenris
* @author svartoyg
*/
/*protected */store(key, value) {
}
@ -80,12 +80,12 @@ class CacheNone extends Cache {
/**
* @author fenris
* @author svartoyg
*/
export class CacheLocalstorage extends Cache {
/**
* @param {string} [corner] for separating the cache instance from others
* @author fenris
* @author svartoyg
*/
/*public */constructor(corner = null) {
super();
@ -93,21 +93,21 @@ export class CacheLocalstorage extends Cache {
}
/**
* @author fenris
* @author svartoyg
*/
/*private */augmentKey(key) {
return ((this.corner === null) ? key : (this.corner + '/' + key));
}
/**
* @author fenris
* @author svartoyg
*/
/*protected */has(key) {
return (window.localStorage.getItem(this.augmentKey(key)) !== null);
}
/**
* @author fenris
* @author svartoyg
*/
/*protected */fetch(key) {
const valueRaw = window.localStorage.getItem(this.augmentKey(key));
@ -116,7 +116,7 @@ export class CacheLocalstorage extends Cache {
}
/**
* @author fenris
* @author svartoyg
*/
/*protected */store(key, value) {
const valueRaw = JSON.stringify(value);

View file

@ -3,7 +3,7 @@
* @param {string} path
* @return Promise<string>
* @todo use Util.fetch instead?
* @author fenris
* @author svartoyg
*/
export async function read (path) {
return (

View file

@ -7,7 +7,7 @@ import {read as fileRead} from './file';
* the relative path to the directory containing the JSON localization files
*
* @var {string}
* @author fenris
* @author svartoyg
*/
var _directory = 'loc';
@ -16,7 +16,7 @@ var _directory = 'loc';
* the default language to use
*
* @var {string}
* @author fenris
* @author svartoyg
*/
var _languageDefault = null;
@ -25,14 +25,14 @@ var _languageDefault = null;
* the fallback language to use
*
* @var {string}
* @author fenris
* @author svartoyg
*/
var _languageFallback = null;
/**
* @var {Cache}
* @author fenris
* @author svartoyg
*/
var _cache = null;
@ -41,7 +41,7 @@ var _cache = null;
* two level map with ISO-639-1 code as first key and translation id as second key
*
* @var {Map<string,Map<string,string>>}
* @author fenris
* @author svartoyg
*/
var _data = {};
@ -49,7 +49,7 @@ var _data = {};
/**
* @param {string} language
* @return Promise<Map<string,string>>
* @author fenris
* @author svartoyg
*/
async function retrieveData (language) {
const regexp = (new RegExp("^([a-z]{2})$"));
@ -77,7 +77,7 @@ async function retrieveData (language) {
/**
* @param {string} languageDefault
* @param {string} [languageFallback]
* @author fenris
* @author svartoyg
*/
export async function initialize (languageDefault, languageFallback = 'en') {
_cache = new CacheLocalstorage('loc');
@ -103,7 +103,7 @@ export async function initialize (languageDefault, languageFallback = 'en') {
* @param {string} key
* @param {string} [languageChosen]
* @return {string}
* @author fenris
* @author svartoyg
*/
export function translate (key, languageChosen = _languageDefault) {
let result = undefined;