I was reading Mozilla documentation and found the function i18n.detectLanguage(). The document states that it can be used in the following way:
var detectingLanguages = browser.i18n.detectLanguage(
text // string
)
However, when I try to use the code above in my Vue application I just get variable not defined on browser
.
How can I use the builtin i18n API which should be supported in all browsers except Safari?
The API is only available in browser extensions, not for scripts on the page.
You can see that in the breadcrumbs of the page:
Mozilla > Add-ons > Browser Extensions > JavaScript APIs > i18n > i18n.detectLanguage()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
And also the URL:
https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/i18n/detectLanguage
^^^^^^^^^^^^^^^^^^^^^