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

angular-locale

v0.3.1

Published

Currency and Locale manager for AngularJS

Downloads

1,567

Readme

Angular Locale

Currency and Locale manager for AngularJS

Usage

Reference script

<script src="angular-locale.min.js"></script>

Inject vtex.ngLocale

angular.module 'yourApp', ['vtex.ngLocale']

Events

localeSelected.vtex

  • LocaleService automatically listens to this and expects lang arguments.
  • lang follows 'xx-XX' format, e.g.: 'en-US'.
  • Therefore both tmhDynamicLocale and $translate (in this order) are called and updated with new i18n data.

localeUpdated.vtex

  • LocaleService triggers this once it has set $translate to use new language and i18n is updated. Obs: setCurrency is called everytime language/locale gets updated, since it will reset $locale.NUMBER_FORMATS each time.

currencyUpdated.vtex

  • LocaleService triggers this once it has set $locale according to current currency configuration.

API LocaleService

setLanguage language

  • string eventName, Object data with any information you want to be registered within the event

setCurrency currencyConfiguration

  • currencyConfiguration Object for United States Dollar:
currencySymbol: '$ '
decimalSeparator: ','
groupSeparator: '.'
ngPatterns:
  gSize: 3
  lgSize: 3
  macFrac: 0
  maxFrac: 2
  minFrac: 2
  minInt: 1
  negPre: "- \u00a4"
  negSuf: ""
  posPre: "\u00a4"
  posSuf: ""

This gets mapped into Angular's $locale:

$locale.NUMBER_FORMATS.CURRENCY_SYM = currencyConfiguration.currencySymbol
$locale.NUMBER_FORMATS.DECIMAL_SEP = currencyConfiguration.decimalSeparator
$locale.NUMBER_FORMATS.GROUP_SEP = currencyConfiguration.groupSeparator
$locale.NUMBER_FORMATS.PATTERNS[1] = currencyConfiguration.ngPatterns

Obs: ngPatterns/NUMBER_FORMATS.PATTERNS[1] has a default value, no worries :)

Development

Inside src you can find this module source code, written in CoffeeScript. To build the .js and uglify it, install npm dev-dependencies and run grunt:

(sudo) npm i
grunt