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

tribusjs

v1.1.0

Published

Translate your webapp, site or whatever using JS

Downloads

10

Readme

Tribus

Tribus is a small and simple library to translate texts. It catches the user's browser language to choose the text.

Install

npm install --save tribusjs

Usage

import Tribus from 'tribusjs';

var langs = {
  'pt-br': {
    // Notificações
    "notify_user_already_exists": "Este email ({email}) já está sendo usado por outra pessoa.",
    "notify_user_doest_not_exists": "Não foi encontrado nenhum usuário.",
    "notify_user_auth_error": "Você digitou sua senha corretamente?",
    "notify_user_create_account_success": "Sua conta foi criada com sucesso! Estamos redirecionando você para o painel...",
    "notify_default": "Não foi possível terminar a operação, por favor, tente novamente.",
    "notify_ok": "<a href="{href}">Ok. Eu entendi.</a>"
  },

  'en-us': {
    // Notifications
    "notify_user_already_exists": "This email ({email}) is already used by someone else.",
    "notify_user_doest_not_exists": "No user was found.",
    "notify_user_auth_error": "You typed your password correctly?",
    "notify_user_create_account_success": "Your account has been successfully created! We are redirecting you to the dashboard...",
    "notify_default": "Could not finish the operation, please try again.",
    "notify_ok": "<a href="{href}">Ok. I got it.</a>"
  },

  'de': {
     // Benachrichtigungen
     "notify_user_already_exists": "Diese E-Mail ({email}) ist bereits von jemand anderem verwendet wird."
     "notify_user_doest_not_exists": "Kein Benutzer gefunden wurde.",
     "notify_user_auth_error": "Sie gaben Ihr Kennwort richtig?",
     "notify_user_create_account_success": "Ihr Konto wurde erfolgreich erstellt Wir werden Sie auf dem Armaturenbrett ...",
     "notify_default": "Der Vorgang konnte nicht abgeschlossen haben, versuchen Sie es erneut."
     "notify_ok": "<a href="{href}"> Ok, ich habe es..</a>"
  },

  'es': {
     // Notificaciones
     "notify_user_already_exists": "Este correo ({email}) electrónico está ya utilizados por otra persona.",
     "notify_user_doest_not_exists": "No se encontró el usuario.",
     "notify_user_auth_error": "Ha escrito la contraseña correctamente?",
     "notify_user_create_account_success": "Su cuenta ha sido creada con éxito te vamos a redirigir el salpicadero ...",
     "notify_default": "No se pudo terminar la operación, por favor intente de nuevo.",
     "notify_ok": "<a href="{href}"> Ok lo tengo.</a>".
  }
};

let t = new Tribus(langs);

// User language is 'pt-br'
t.print('notify_user_already_exists', { email: '[email protected]' }); // Este email ([email protected]) já está sendo usado por outra pessoa.

// User language is 'de'
t.print('notify_user_already_exists', { email: '[email protected]' }); // Diese E-Mail ([email protected]) ist bereits von jemand anderem verwendet wird.

// Replace variable data
t.print('notify_ok', { href: 'http://google.com' }, 'es'); // <a href="http://google.com"> Ok lo tengo.</a>

// Change the DOM; Simple example
document.body.innerHTML = t.print('notify_ok', { href: 'http://github.com' }); // <a href="http://github.com"> Ok lo tengo.</a>

// Override language; User language is 'de'
t.print('notify_user_doest_not_exists', 'en-us'); // No user was found.

// User language is 'de' but suppose it doesn't exist; Get the default 'en-us'
t.print('notify_user_auth_error'); // You typed your password correctly?

API

Tribus (object languages_objects [, string defaultLang = 'en-us'] [, string language_default = USER_BROSWER_LANGUAGE])

string Tribus.print (string key, [, object supplant] [, string override_user_browser_language])

string Tribus.print (string key, [, string override_user_browser_language])

Important!

The translation object keys must be all lowercase.

For example:

// good
{
  'en-us': {...},
  'de': {...},
  'es': {...},
  'pt-br': {...}
}

// bad
{
  'EN-US': {...},
  'DE': {...},
  'ES': {...},
  'PT-BR': {...}
}

View all language codes

Tests

To run the tests: npm install && npm test

Using jest to testing.