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

@airtame/translation

v1.0.3

Published

A library to maintain and update translation in ARC projects.

Downloads

2

Readme

Translation

This package has two purposes:

  1. A CLI tool translation check|update|placeholders to check the current translations, run updates on existing translation or to update the placeholders with values from the translation file.
  2. Expose for consumers two function. The first one is setTranslations(translationObject) used to populate the translations the package has access to. The second one is the default exported function t(label, placeholder, parametersObject) that is meant to match a label to a translation from provided translation object, or populate that translation with the placeholder or label provided by the function caller.

The exposed function for the consumer will take note of NODE_ENV used and for any values other than production it will "highlight" missing translation directly into the application. ( It mainly prepends ⚠️ character to the placeholder strings ).

Installation

npm install --save-exact @airtame/translation

CLI

translations check|update|placeholders

or

translation c|u|p

Following environment variables will be used with the CLI command tool:

  • TRANSLATION_API_KEY (required) - Auth token value to call localise.biz api with.
  • TRANSLATION_FILE (required for update command, optional for the others) - the location of the main english translation json file. It defaults to the location of the file in the arc project for check and placeholders commands.
  • TRANSLATION_PROJECT_FILES_GLOB - the glob pattern to target project files where to run the check and placeholders scripts against. It defaults to ./src/**/*.{ts,tsx} value.
  • TRANSLATION_IGNORE_PROJECT_FILES_GLOB - the glob pattern to ignore files matched by previous mentioned glob (TRANSLATION_PROJECT_FILES_GLOB). It defaults to **/*.stories.tsx value.

Check translations:

translations check|c

Update translations:

translations update|u

Update translations placeholders:

translations placeholders|p

Using inside the application:

// "./src/i18n/i18n.ts"

import t, { setTranslations } from "@airtame/translation";
import en from "../some/path/to/a/file.json";
setTranslations(en);
export default t;

Development

Installation

nvm install
nvm use
npm ci;

Test

npm test;

Build

npm build;

Testing the project


Testing project exported library/contents:

For testing the exported functions in a project, in order to avoid having to publish new releases for every checked change to the library we can use Yalc to create a local repository.

1. Install yalc

Install yalc globally with npm install -g yalc so that you can use it from the command line.

2. Publish airtame/translation to yalc

In the Airtame UI folder run npm run build && yalc publish to publish the library in its current state to the local repository.

3. Install airtame/translation from yalc

In your project's folder run yalc add @airtame/translation to install translation Package

4. Make changes to translation package

After making changes to the library, update the local repository with npm run build && yalc push. The dependency will be automatically updated in the project.

5. Clean up after yourself

When you're done, remove the package with yalc remove @airtame/translation. This will remove the local dependency and restore the original from the internal package repository.


Test the command line tool scripts

For testing the command line scripts, Yalc does not support this, so we will have to install it locally.

1. Build and pack by running the following command npm run build && npm pack;
2. Copy the ABSOLUTE path of the newly created .tgz file ( For exmaple, the absolute path is /Users/broscaru/airtame/translation/airtame-translation-0.0.0.tgz; We copy this to clipboard ).
3. In the project you wish to test out the CLI tool, we go in and install the package by providing the absolute path npm install /Users/broscaru/airtame/translation/airtame-translation-0.0.0.tgz to the npm install command.
4. In the project package.json file, under the scripts add an entry: "translation": "translation"
5. Run the command npm run translation -- c|u|p to test the command line scripts.

Releasing a new version:

npm version minor

CHANGELOG