
Product
Introducing Scala and Kotlin Support in Socket
Socket now supports Scala and Kotlin, bringing AI-powered threat detection to JVM projects with easy manifest generation and fast, accurate scans.
ember-best-language
Advanced tools
A FastBoot-enabled addon to detect the best language for your user.
$ ember install ember-best-language
ember-best-language
uses a scoring system to determine the best language to use. The scoring system is based on the Accept-Language
header on the FastBoot-side. On the client side, we use navigator.languages
and give a score to each language based on its order in the array.
ember-best-language
also split language code from country code to make sure that if the user reads fr-CA
and your system supports fr
, you will have a match.
This addon is inspired by the work of Rémi Prévost in plug_best
, you should check it out!
ember-best-language
provides a service with two methods:
To find out which language is the best one to use among a list of supported languages:
import Route from '@ember/routing/route';
import {inject as service} from '@ember/service';
export default class extends Route {
@service('best-language') bestLanguage;
beforeModel() {
const bestLanguage = this.bestLanguage.bestLanguage(['en-US', 'fr']);
// => {language: 'en-US', baseLanguage: 'en', score: 1}
}
});
If none of the user’s languages are supported, ember-best-language
will return null
. However, you can use the bestLanguageOrFirst
method to make it return the first supported language in those cases.
import Route from '@ember/routing/route';
import {inject as service} from '@ember/service';
export default class extends Route {
@service('best-language') bestLanguage;
beforeModel() {
const bestLanguage = this.bestLanguage.bestLanguage(['fr', 'de', 'en-US']);
// => null
const bestLanguageOrFirst = this.bestLanguage.bestLanguageOrFirst(['fr', 'de', 'en-US']);
// => {language: 'fr', baseLanguage: 'fr', score: 0}
}
});
$ git clone https://github.com/mirego/ember-best-language
$ cd ember-best-language
$ yarn install
$ yarn test # Runs `ember try:each` to test the addon against multiple Ember versions
$ ember test
$ ember test --server
$ ember build
For more information on using ember-cli, visit https://ember-cli.com.
ember-best-language
is © 2017-2022 Mirego and may be freely distributed under the New BSD license. See the LICENSE.md
file.
The flag logo is based on this lovely icon by Prasanta Kr Dutta, from The Noun Project. Used under a Creative Commons BY 3.0 license.
Mirego is a team of passionate people who believe that work is a place where you can innovate and have fun. We're a team of talented people who imagine and build beautiful Web and mobile applications. We come together to share ideas and change the world.
We also love open-source software and we try to give back to the community as much as we can.
FAQs
A FastBoot-enabled addon to detect the best language for your user.
The npm package ember-best-language receives a total of 7 weekly downloads. As such, ember-best-language popularity was classified as not popular.
We found that ember-best-language demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports Scala and Kotlin, bringing AI-powered threat detection to JVM projects with easy manifest generation and fast, accurate scans.
Application Security
/Security News
Socket CEO Feross Aboukhadijeh and a16z partner Joel de la Garza discuss vibe coding, AI-driven software development, and how the rise of LLMs, despite their risks, still points toward a more secure and innovative future.
Research
/Security News
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.