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

s-ago-translate

v1.1.1

Published

A package based in 's-ago' that I made to take the functionality of the 'ago' function and translate it to many languages.

Downloads

6

Readme

S-Ago Translate

NPM Travis (.com) Libraries.io dependency status for latest release npm npm bundle size npm GitHub Repo stars

A package based in 's-ago' that I made to take the functionality of the 'ago' function and translate it to many languages.

Instalation

npm i s-ago-translate

Usage

It has the same usage as the ago function from s-ago, but you need to pass a new parameter named lang that must be a property from the exported object Langs. This parameter is the language in that you want the human readable text. You can find them in the Langs object, followed by a language codes according to ISO 639-1.

The Following example is also from the s-ago package, but the code is modified to add the new parameter.

const {ago, Langs} = require('s-ago-translate');

// Or if you are using import-export
// import { ago, Langs } from 's-ago-translate'

let now = Date.now();
let hoursAgo = new Date(now - (6 * 60 * 60 * 1000));
let yesterday = new Date(now - (24 * 60 * 60 * 1000));

// In newer versions, you don't need to convert the miliseconds to a Date object
// this is very useful because, in some cases, you store created or edited dates
// in databases as numbers indicating miliseconds.
let tomorrow = now + (24 * 60 * 60 * 1000);
let inSixHours = now + (6 * 60 * 60 * 1000);
let inTwoWeeks = now + (2 * 7 * 24 * 60 * 60 * 1000);
 
// present
ago(now, Langs.EN); // 'just now', the used TLP was EN (english)
 
// past
ago(yesterday, Langs.ES); // 'ayer' (yesterday), the used TLP was ES (spanish)
ago(hoursAgo, Langs.ES); // 'hace 6 horas' (6 hours ago), the used TLP was ES (spanish)
 
// future
ago(inSixHours, Langs.IT); // 'in 6 ore' (in 6 hours), the used TLP was IT (italian)
ago(tomorrow, Langs.IT); // 'domani' (tomorrow), the used TLP was IT (italian)
 
// max unit
ago(inTwoWeeks, Langs.FR);  // 'dans 2 semaines' (in 2 weeks), the used TLP was FR (french)
ago(inTwoWeeks, Langs.FR, 'day'); // 'dans 14 jours' (in 14 days), the used TLP was FR (french)

In cases where you want to translate to only 1 language (like spanish for example) you can only import the required Lang.

const {ago, Langs:{ES}} = require('s-ago-translate')

const now = new Date()

ago(now, ES) // en este momento

For more information about how the ago function works, visit the s-ago npm page.

Available Languages

These are the availables Langs.

  • English (Langs.EN)
  • Spanish (Langs.ES)
  • Portuguese (Langs.PT)
  • German (Langs.DE)
  • French (Langs.FR)
  • Italian (Langs.IT)

These are Langs NOT AVAILABLE yet, but that will be in a future (or that's the idea).

  • Dutch (Langs.NL)
  • Polish (Langs.PL)
  • Ukrainian (Langs.UK)
  • Russian (Langs.RU)
  • Turkish (Langs.TR)
  • Japanese (Langs.JA)
  • Korean (Langs.KO)
  • Thai (Langs.TH)
  • Chinese (Langs.ZH)