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

fecha-locales

v0.2.1

Published

i18n locales for fecha.js

Downloads

107

Readme

  • fecha-locales ~fecha-locales~ provides different locales to be used for internationalization support in fecha. All the locale modules provided by ~fecha-locales~ can be used in [[https://github.com/taylorhakes/fecha#i18n-support][i18n support provided by fecha.js]].

** Installation *** Npm #+begin_src bash npm install --save fecha-locales #+end_src *** Browser #+begin_src html

#+end_src ** Usage *** Npm Import/require the locale(s) you need, and put the one you want to use as fecha.i18n

#+begin_src javascript import fr from 'fecha-locales/locales/fr';

fecha.i18n = fr; #+end_src *** Browser For browser,

  • Include fecha-locales before your app (i.e script that is going to use fecha-locales).
  • Doing so will export ~window.fechaLocales~ object
  • You can add multiple locales
  • All the locales you create will be added to ~window.fechaLocales.~
  • In your app, you can now do ~fecha.i18n = fechaLocales.~ #+begin_src javascript // In html

// In app.js fecha.i18n = fechaLocales.; #+end_src ** Credits All the fecha-locales are built from [[https://github.com/moment/moment][moment.js]]. All credit for collecting the locales go to momentjs. This module uses a small build script to convert moment-locales to fecha friendly locales (i.e which can be put simply as value of ~fecha.i18n~) ** FAQ *** The locale I need is not present in ~fecha-locales/locales/~ but it is present in moment-locales All the moment-locales couldn't get converted to fecha. So the ones which failed to convert are placed as ~fecha-locales/locales/~, but please don't use them. If you need a locale which is present as ~fecha-locales/locales/~, please do one of these:

  • Create an issue and I'll fix it
  • Create a pull request with the fix. To create a fix:
    • Clone/fork this repository, cd to it, and install npm dependencies #+begin_src bash git clone https://github.com/channikhabra/fecha-locales.git cd fecha-locales npm install #+end_src
    • Run build-locales script #+begin_src javascript npm run build-locales #+end_src
    • Now you'll see some messages in the console which will tell you which properties are facing problems. Search for the ~<locale-name.js>~ to see which properties you need to fix. For example, if you're fixing ~es~ locale, you need to look for these messages: #+begin_src bash Invalid value for monthsShort of "es.js". Please fix it manually. Invalid value for DoFn of "es.js". Please fix it manually. #+end_src
    • Create ~fecha-locales/locale-builder/fixers/.js~ file
    • Now ~module.exports~ an object from this file, which should contain the keys which are causing problems and put the fixes for them as their values. Make sure you first check ~fecha-locales/locales/_.js~ file for clues. For ~es~ locale, following should fix the building of locale: #+begin_src javascript // fecha-locales/locale-builder/fixers/es.js module.exports = { DoFn: (number) => { // in moment/locales/es, this is given as %dº, but fecha need it to be a function, so we make it a function instead return number + 'º'; }, monthsShort: ['enero', 'feb.', 'marzo', 'abr.', 'mayo', 'jun.', 'jul.', 'agosto', 'sept.', 'oct.', 'nov.', 'dic.'] }; #+end_src
    • Now run ~npm run build-locales~ again, and ~fecha-locales/locales/.js~ shall be there.
    • Create a PR (Thanks for creating the PR, you're awesome!) *** Why did you use esprima and friends to convert moment locales to fecha? Wasn't there an easier way of doing so? Not sure about easier, but yes this can be done in other ways. I was feeling fancy so I went with esprima. Besides, this is the most explicit and flexible way of conversion imo.