Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

lang-list

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lang-list

Node.js lib helps to retrieve a list of supported languages to be used in web apps UI.

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
357
decreased by-21.54%
Maintainers
1
Weekly downloads
 
Created
Source

lang-list

Build Status

Node.js lib helps to retrieve a list of supported languages to be used in web apps UI.

Usage

require lang-list lib

var LangList = require('lang-list');

LangList.getList()

This function will retrieve a list of supported languages to be used in web apps UI based on the passed config object.

Arguments:

NAMETYPEDEFAULTREQUIREDDESCRIPTION
supportedLangsArray of StringsYESRetrieve only the supported languages for your web app.
strictBooleanfalseNORetrieve only the supported languages with strict codes only

Examples:

var languagesArr = LangList.getList({ supportedLangs: ['ar', 'en', 'fr', 'es'] });
/*
languagesArr will be: 
[
    {
        "code": "ar",
        "int": "Arabic",
        "native": "العربية",
    },
    {
        "code": "en",
        "int": "English",
        "native": "English",
    },
    {
        "code": "fr",
        "int": "French",
        "native": "Français",
    },
    {
        "code": "es",
        "int": "Spanish",
        "native": "Español",
  }
]
*/
// calling `getList` with strict = true.
var strictLanguagesArr = LangList.getList({ supportedLangs: ['ar_AR', 'en_US', 'fr_CA', 'es_ES'], strict: true );
/*
languagesArr will be: 
[
    {
        "code": "ar_AR",
        "int": "Arabic",
        "native": "العربية"
    },
    {
        "code": "en_US",
        "int": "English (US)",
        "native": "English (US)"
    },
    {
        "code": "fr_CA",
        "int": "French (Canada)",
        "native": "Français (Canada)"
    },
    {
        "code": "es_ES",
        "int": "Spanish (Spain)",
        "native": "Español (España)"
    },
  }
]
*/

With Handlebars Example:

    <ul class="dropdown-menu">
        {{#each languagesArr}}
        <li><a href="?lang={{code}}">{{native}}</a>
        {{/each}}
    </ul>

License

Copyright 2016, Yahoo Inc.

Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.

Keywords

FAQs

Package last updated on 24 Oct 2023

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc