aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefanVukovic99 <stefanvukovic44@gmail.com>2024-05-09 03:10:48 +0200
committerGitHub <noreply@github.com>2024-05-09 01:10:48 +0000
commit57d928bb82130f8f1dcbc85ddd5430721a0dbf04 (patch)
tree1c6c63a267a9eda67c17b16dd38ed89a76d6cc84
parentd6b3745b7fe983e1397a00f4cb0cea53cbc61f22 (diff)
add source and target language dictionary metadata (#891)
* add source and target language dictionary metadata * validate iso * add description and grc
-rw-r--r--ext/data/schemas/dictionary-index-schema.json15
-rw-r--r--ext/js/dictionary/dictionary-importer.js4
-rw-r--r--ext/js/pages/settings/dictionary-controller.js6
-rw-r--r--types/ext/dictionary-data.d.ts2
-rw-r--r--types/ext/dictionary-importer.d.ts2
5 files changed, 26 insertions, 3 deletions
diff --git a/ext/data/schemas/dictionary-index-schema.json b/ext/data/schemas/dictionary-index-schema.json
index 56726668..27d525c7 100644
--- a/ext/data/schemas/dictionary-index-schema.json
+++ b/ext/data/schemas/dictionary-index-schema.json
@@ -1,6 +1,13 @@
{
"$id": "dictionaryIndex",
"$schema": "http://json-schema.org/draft-07/schema#",
+ "definitions": {
+ "isoLanguageCode": {
+ "type": "string",
+ "description": "ISO language code (ISO 639-1 where possible, ISO 639-3 otherwise).",
+ "pattern": "^(aa|ab|ae|af|ak|am|an|ar|as|av|ay|az|az|ba|be|bg|bh|bi|bm|bn|bo|br|bs|ca|ce|ch|co|cr|cs|cu|cv|cy|da|de|dv|dz|ee|el|en|eo|es|et|eu|fa|ff|fi|fj|fo|fr|fy|ga|gd|gl|gn|grc|gu|gv|ha|he|hi|ho|hr|ht|hu|hy|hz|ia|id|ie|ig|ii|ik|io|is|it|iu|ja|jv|ka|kg|ki|kj|kk|kl|km|kn|ko|kr|ks|ku|kv|kw|ky|la|lb|lg|li|ln|lo|lt|lu|lv|mg|mh|mi|mk|ml|mn|mr|ms|mt|my|na|nb|nd|ne|ng|nl|nn|no|nr|nv|ny|oc|oj|om|or|os|pa|pi|pl|ps|pt|qu|rm|rn|ro|ru|rw|sa|sc|sd|se|sg|si|sk|sl|sm|sn|so|sq|sr|ss|st|su|sv|sw|ta|te|tg|th|ti|tk|tl|tn|to|tr|ts|tt|tw|ty|ug|uk|ur|uz|ve|vi|vo|wa|wo|xh|yi|yo|za|zh|zu)$"
+ }
+ },
"type": "object",
"description": "Index file containing information about the data contained in the dictionary.",
"required": [
@@ -47,6 +54,14 @@
"type": "string",
"description": "Attribution information for the dictionary data."
},
+ "sourceLanguage": {
+ "$ref": "#/definitions/isoLanguageCode",
+ "description": "Language of the terms in the dictionary."
+ },
+ "targetLanguage": {
+ "$ref": "#/definitions/isoLanguageCode",
+ "description": "Main language of the definitions in the dictionary."
+ },
"frequencyMode": {
"type": "string",
"enum": ["occurrence-based", "rank-based"]
diff --git a/ext/js/dictionary/dictionary-importer.js b/ext/js/dictionary/dictionary-importer.js
index 310b2ec1..f0c92481 100644
--- a/ext/js/dictionary/dictionary-importer.js
+++ b/ext/js/dictionary/dictionary-importer.js
@@ -285,12 +285,14 @@ export class DictionaryImporter {
counts
};
- const {author, url, description, attribution, frequencyMode} = index;
+ const {author, url, description, attribution, frequencyMode, sourceLanguage, targetLanguage} = index;
if (typeof author === 'string') { summary.author = author; }
if (typeof url === 'string') { summary.url = url; }
if (typeof description === 'string') { summary.description = description; }
if (typeof attribution === 'string') { summary.attribution = attribution; }
if (typeof frequencyMode === 'string') { summary.frequencyMode = frequencyMode; }
+ if (typeof sourceLanguage === 'string') { summary.sourceLanguage = sourceLanguage; }
+ if (typeof targetLanguage === 'string') { summary.targetLanguage = targetLanguage; }
return summary;
}
diff --git a/ext/js/pages/settings/dictionary-controller.js b/ext/js/pages/settings/dictionary-controller.js
index a0e0c196..f0450892 100644
--- a/ext/js/pages/settings/dictionary-controller.js
+++ b/ext/js/pages/settings/dictionary-controller.js
@@ -211,12 +211,14 @@ class DictionaryEntry {
* @returns {boolean}
*/
_setupDetails(detailsTable) {
- /** @type {[label: string, key: 'author'|'url'|'description'|'attribution'][]} */
+ /** @type {[label: string, key: 'author'|'url'|'description'|'attribution'|'sourceLanguage'|'targetLanguage'][]} */
const targets = [
['Author', 'author'],
['URL', 'url'],
['Description', 'description'],
- ['Attribution', 'attribution']
+ ['Attribution', 'attribution'],
+ ['Source Language', 'sourceLanguage'],
+ ['Target Language', 'targetLanguage']
];
const dictionaryInfo = this._dictionaryInfo;
diff --git a/types/ext/dictionary-data.d.ts b/types/ext/dictionary-data.d.ts
index 0128f83f..68752bbb 100644
--- a/types/ext/dictionary-data.d.ts
+++ b/types/ext/dictionary-data.d.ts
@@ -29,6 +29,8 @@ export type Index = {
url?: string;
description?: string;
attribution?: string;
+ sourceLanguage?: string;
+ targetLanguage?: string;
frequencyMode?: 'occurrence-based' | 'rank-based';
tagMeta?: IndexTagMeta;
};
diff --git a/types/ext/dictionary-importer.d.ts b/types/ext/dictionary-importer.d.ts
index 3a320f96..8807b3bc 100644
--- a/types/ext/dictionary-importer.d.ts
+++ b/types/ext/dictionary-importer.d.ts
@@ -65,6 +65,8 @@ export type Summary = {
url?: string;
description?: string;
attribution?: string;
+ sourceLanguage?: string;
+ targetLanguage?: string;
frequencyMode?: 'occurrence-based' | 'rank-based';
};