How to use language-tags - 5 common examples

To help you get started, we’ve selected a few language-tags examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github wooorm / dictionaries / script / generate.js View on Github external
value.forEach(function(subvalue) {
        var subtag = subvalue ? tags.type(subvalue, label) : null
        var data = subtag ? subtag.data.record.Description : null

        if (data) {
          // Fix bug in `language-tags`, where the description of a tag when
          // indented is seen as an array, instead of continued text.
          if (subtag.data.subtag === 'ia') {
            data = [data.join(' ')]
          }

          keywords = keywords.concat(
            data
              .join(' ')
              .toLowerCase()
              .split(' ')
          )
github BelkaLab / react-translatable-input / src / TranslatableInput.js View on Github external
renderFlag(option) {
    const { showLanguageName, langTranslator } = this.props;
    const tag = tags(option.value);
    let langClasses = '';

    if (tag.valid() === false) {
      // the default language
      const defaultName = typeof (langTranslator) === 'function' ? langTranslator('default') : 'default';
      return (
        <div>
          <div title="{option.value}">
          { showLanguageName ? <div title="{defaultName}">{defaultName}</div> : null }
        </div>
      );
    }
</div>
github AtomLinter / linter-spell / lib / language-range.js View on Github external
static parse (name) {
    let parts = name.split(/[-_]/)
    let i = 0
    let lang = []
    for (const type of ['language', 'extlang', 'script', 'region', 'variant']) {
      if (i &lt; parts.length) {
        lang.push((tags.type(parts[i], type) &amp;&amp; (type !== 'region' || parts[i].match(/^[A-Z]+$/))) ? parts[i++] : '*')
      }
    }
    return _.dropRightWhile(lang, p =&gt; p === '*').join('-') || '*'
  }
github AtomLinter / linter-spell / lib / language-helpers.js View on Github external
export function parseRange (name) {
  let parts = name.split(/[-_]/)
  let i = 0
  let lang = []
  for (const type of ['language', 'extlang', 'script', 'region', 'variant']) {
    if (i &lt; parts.length) {
      lang.push((tags.type(parts[i], type) &amp;&amp; (type !== 'region' || parts[i].match(/^[A-Z]+$/))) ? parts[i++] : '*')
    }
  }
  return _.dropRightWhile(lang, p =&gt; p === '*').join('-') || '*'
}
github BelkaLab / react-translatable-input / src / TranslatableInput.js View on Github external
                              .filter(l => tags(l).valid())
                              .map(tag => ({ label: tag, value: tag }));

language-tags

Work with IANA language tags.

MIT
Latest version published 6 days ago

Package Health Score

74 / 100
Full package analysis

Popular language-tags functions