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

@narando/express-preferred-ui-language

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@narando/express-preferred-ui-language

A middleware to set the available system languages for use with mustache.

  • 0.23.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

@narando/express-preferred-ui-language

A middleware to set the available system languages for use with mustache.

Getting Started

You need to have nodejs, npm, express and mustache installed.

$ npm install @narando/express-preferred-ui-language

Usage

The middleware will get the availabel languages from ./app/locales/:

import preferredUILanguage from "@narando/express-preferred-ui-language";

// add middleware to express
app.router(preferredUILanguage());

To add a language you have to create a new file at ./app/locales. The file name will be used as the language identifier.

Use the following JSON structure and folder structure

Folder structure
app
|-locales
  |-de-DE.json
  |-en-US.json
Locale file structure
{
  "namespace1": {
    "text1": "First text",
    "text2": "Second text"
  },
  "namespace2": {
    "text3": "Third text",
    "text4": "Fourth text"
  }
}

The middleware will set the res.locals like:

[
  { languageCode: "de-DE", selected: true },
  { languageCode: "en-US", selected: false }
]

To use it in your mustache template you can use the following example to create a dropdown with all available languages

<select name="systemLanguage" id="selectSystemLanguage" class="selectpicker form-control" data-live-search="true">
  {{#UILanguage}}
      <option value="{{languageCode}}" {{#selected}} selected {{/selected}}>{{languageCode}}</option>
  {{/UILanguage}}
</select>

Keywords

FAQs

Package last updated on 04 Feb 2019

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