UNPKG

browser-language-detector

Version:

A lightweight cross-browser JavaScript library for detecting browser and user language

17 lines (13 loc) 422 B
import Detector from '../Detector'; class HTMLTagDetector extends Detector { detect() { const htmlTag = typeof document !== 'undefined' ? document.documentElement : null; if (htmlTag && typeof htmlTag.getAttribute === 'function') { const lang = htmlTag.getAttribute('lang'); this.languages = [lang]; this.data = {lang}; } return super.detect(); } } export default HTMLTagDetector;