Jonatan
Jonatan

Reputation: 1242

Using i18n.detectLanguage() in Vue

I was reading Moxilla 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?

Upvotes: 0

Views: 1152

Answers (1)

VLAZ
VLAZ

Reputation: 29007

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
                                                 ^^^^^^^^^^^^^^^^^^^^^

Upvotes: 6

Related Questions