In Browser Language
Get the language of the browser
Install / Use
npx skills add kchapelier/in-browser-languageInstalls into whichever agent you are using.
README
in-browser-language
This module is designed to be used with browserify or other CJS bundlers.
npm i in-browser-language --save
How it works
The module checks for (in order) :
window.navigator.languageswindow.navigator.languagewindow.clientInformation.userLanguagewindow.clientInformation.browserLanguagewindow.clientInformation.systemLanguage
Some systems / browser may actually return the language of the OS instead of the language of the browser.
There is no way around this issue but it can be mitigated by allowing the user to change its language.
Methods
list()
Return an array containing the languages.
first()
Return the first language of the list.
pick(proposedLanguages, defaultLanguage)
Pick the first language found both in the proposedLanguages array and the list of languages supported by the browser.
If there are no matches, the defaultLanguage is returned.
var browserLanguage = require('in-browser-language');
console.log(browserLanguage.list());
// returns ['fr', 'en']
console.log(browserLanguage.first());
// returns 'fr'
console.log(browserLanguage.pick(['pl', 'ja', 'en', 'fr']));
// returns 'fr' as 'fr' is the first declared by the browser
console.log(browserLanguage.pick(['pl', 'ja'], 'pl'));
// returns 'pl' as there are no matches
console.log(browserLanguage.pick(['pl', 'ja']));
// returns null as there are no matches and no defaultLanguage
History
1.0.3 (2018-09-18)
- Remove
uniqdependency.
Related Skills
node-connect
385.5kDiagnose OpenClaw Android, iOS, or macOS node pairing, QR/setup code, route, auth, and connection failures.
blender-python-addon
40.5kBlender Python add-on rules for operators, panels, properties, registration, testing, and API-safe scripting
flutter-development-guidelines-cursorrules-prompt-file
40.5kCursor rules for Flutter development with MVVM architecture, Riverpod state management, Material widgets, and Dart style guidelines.
commit-push-pr
140.6kCommit, push, and open a PR
