npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

i18ninput

v1.0.16

Published

[![Build Status](https://travis-ci.org/braandl/i18nInput.svg?branch=master)](https://travis-ci.org/braandl/i18nInput)

Downloads

55

Readme

i18nInput

Build Status

Install

Download required dependencies using npm and create packed distribution files using gulp, or download the entire project and sample files.

 $ npm install
 $ gulp [pkg]

Requirements

i18nInputView is dependent on the following JavaScript libraries:

  • jQuery

Demo

See demo under https://braandl.github.io/i18nInput

Usage

setup i18nInputView and define languages

    import i18nInputView from 'i18nInput';
    i18nInput = new i18nInputView(['de_DE, en_EN, fr_FR']);

Use a div element to define as the container of the input field.

 <div id="my_i18n"></div>

The create the control, use the i18nInputView function on the ID of the div.

 $(document).ready(function () {
    i18nInput.i18nInputView("my_i18n");
 });

Allowed HTML5 Attributes

<!-- The number of rows (if more than one, the input will be a textarea instead of an input fiel -->
 rows="[0-9]*"

<!-- The width of the element -->
 width="270px"

<!-- The placeholder of the element that is shown when no input was entered. -->
 placeholder="My Placeholder"

<!-- The placeholder can also be of type array and have a single on for each language. -->
 placeholder="['Mein Platzhalter', 'My Placeholder']"

<!-- Array of languages that are offered, the first one will be selected on start -->
 languages="['de_DE', 'en_EN']"

<!-- Classname or classnames of the expander area underneath the input field -->
 expander-class="classname"

<!-- Classname or classnames to style the input field itself -->
 input-class="classname"

<!-- Classname or classnames to style the picker -->
 picker-class="classname"

<!-- Animate FadeIn and Out, default is True -->
 animate="false"

<!-- Prevent submit if not all fields are filled, default is true -->
 submitOnMissing="false"

JavaScript Access


 // Prints all filled in results. Missing fields are not returned.
 $('#my_i18n').i18n();
 <- Array
    /*[de_DE: "Deutsch", nl_NL: "Nederlands",
    en_EN: "English", en_US: "Different English",
    de_AT: "Anderes Deutsch"]*/


 // Prints all filled in results. Missing fields are not returned.
 $('#my_i18n').i18nObject();
 <- Object
    /*{de_DE: "Deutsch", nl_NL: "Nederlands",
    en_EN: "English", en_US: "Different English",
    de_AT: "Anderes Deutsch"}*/

 // Prints all languages that were not filled in.
 $('#my_i18n').missing();
 <- Array
    /* ["de_DE", "de_AT", "en_EN", "en_US", "nl_NL"]; */

 // Prints wheather all Fields were filled or not.
 $('#my_i18n').complete();
 <- Boolean;

 /* Fill the Input Fields with preset Values using scalar Values or Arrays.
   Throws an Exception if Language is not available in definition.
 */
 $('#my_i18n').setValue("de_DE", "Deutsch");
 <- Boolean

 $('#my_i18n').setValue(["de_DE", "en_US"], ["Deutsch", "English"]);
 <- Boolean

 // Returns an Array of all locales that can be used to set up the View.
 $('#my_i18n').allLocales();
 <- Array;

 /* Adds an optional handler that is called when the form submit failed, because of an incomplete data set. */
 $('#my_i18n').registerFormIncompleteHandler(function() { /*...*/ });
 <- Boolean;

 // Enabling / Disabling the input field.
 $('#my_i18n > input').prop('disabled', true);

 // Instead of using jQuery selector, plain JavaScript is okay as well:
 document.getElementById('my_id1').i18n();

Form Handling

As shown in the example below, a i18nInputView can be wrapped in a

<form METHOD="post">
    <div id="my_i18n" languages="['de_DE','de_AT','en_EN']"></div>
</form>

form element. When the form is submitted, the values of the i18nInputView will be appended to the form data as an Array:

    my_i18n[de_DE]:Hallo
    my_i18n[en_EN]:Hello
    my_i18n[de_AT]:Grüezi

an will be transferred to the target as such. You can include as many i18nInputViews into a single form as you wish, short, you can use it just like a normal <input> element.

Not filled languages will be ignored in the form data.

Credits

  • Flag Icon CSS was used to view all the awesome SVG Flags. (https://github.com/lipis/flag-icon-css)

  • Written by Stephan Brandt [email protected]