diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 7ee5603..7d9c0d2 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -220,5 +220,8 @@ }, "error_msg_notattached": { "message": "The product data has not been attached to the storage." + }, + "error_msg_APImissing": { + "message": "You have not yet added the API keys. To continue, please add one in the options." } } diff --git a/scripts/AI/gemini.js b/scripts/AI/gemini.js index 5d7a7b1..7ae6f91 100644 --- a/scripts/AI/gemini.js +++ b/scripts/AI/gemini.js @@ -2,6 +2,8 @@ // Import the file module. // import file from `./net.js`; +const texts = (await import(chrome.runtime.getURL("scripts/read.js"))).default; + // Don't forget to set the class as export default. export default class gemini { #key; @@ -15,7 +17,7 @@ export default class gemini { */ constructor (key, model, version = {"API": "v1beta"}) { if ((key) ? (((typeof key).includes(`str`)) ? !(key.trim()) : true) : true) { - throw new Error(`The API key is required.`); + throw new ReferenceError(texts.localized(`error_msg_APImissing`)); }; // Register the API key privately.