当前位置: 首页 > 软件库 > 程序开发 > >

ember-best-language

授权协议 BSD-3-Clause License
开发语言 JavaScript
所属分类 程序开发
软件类型 开源软件
地区 不详
投 递 者 姚凯歌
操作系统 跨平台
开源组织
适用人群 未知
 软件概览


A FastBoot-enabled addon to detect the best language for your user.

Installation

$ ember install ember-best-language

How does it work?

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!

Usage

ember-best-language provides a service with two methods:

  • bestLanguage
  • bestLanguageOrFirst

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', '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}
  }
});

Contributing

$ git clone https://github.com/mirego/ember-best-language
$ cd ember-best-language
$ yarn install

Running tests

$ yarn test # Runs `ember try:each` to test the addon against multiple Ember versions
$ ember test
$ ember test --server

Building

$ ember build

For more information on using ember-cli, visit https://ember-cli.com.

License

ember-best-language is © 2017-2019 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.

About Mirego

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.

 相关资料
  • Ember Best Practices This package has been deprecated: Please use eslint-plugin-ember. Deprecation details: Rule ID Status no-attrs-snapshot Deprecated in Octane no-attrs Deprecated in Octane no-broke

  • If this page doesn't answer your question, please feel free to open an issue in our repository. The Provider (window.ethereum) ::: tip Recent Breaking Provider Changes If you are an Ethereum applicati

  • Ways to avoid calls to saveLayer(): To implement fading in an image, consider using the FadeInImage widget, which applies a gradual opacity using the GPU’s fragment shader. For more information, see O

  • Best Resume Ever 是一个帮助你快速生成漂亮简历的工具,它基于 Vue 和 LESS,生成的简历可导出为 PDF 格式。     如何使用 best-resume-ever 要求 node v.7.6 及以上版本 克隆存储库 运行 npm install 在 src/person.js 中编辑个人信息  用 npm run dev 进行预览 用 npm run export 导出简历 所有简历将导出至 /pdf 文件内。

  • Translations: Nederlands (by Protoqol) Indonesia (by P0rguy, Doni Ahmad) 한국어 (by cherrypick) 日本語 (by 2bo) 简体中文 (by xiaoyi) 繁體中文 (by woeichern) ภาษาไทย (by kongvut sangkla) বাংলা (by Anowar Hossain) فا

  • Best-of Jupyter ��   A ranked list of awesome Jupyter projects. Updated weekly. This curated list contains 290 awesome open-source projects with a total of 270K stars grouped into 13 categories. All p