Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@guestlinelabs/onekey

Package Overview
Dependencies
Maintainers
0
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@guestlinelabs/onekey

Utility to download translations from the [OneSky](https://www.oneskyapp.com/) and generate typed keys in Typescript for having typed translations.

  • 3.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

onekey

Utility to download translations from OneSky and generate typed keys in Typescript for having typed translations.

Installation

npm install @guestlinelabs/onekey

Usage

There are two main commands to use: Fetch translations and Generate translation keys

Fetch translations

Usage: onekey fetch [options]

Options:

  -o, --out      Path where translations will be saved
  -p, --project  Numeric id of the OneSky project
  -f, --files    Names of the files to download from the OneSky project separated by commas
  -s, --secret   OneSky private key (it can be read from environment variable ONESKY_PRIVATE_KEY)
  -k, --apiKey   OneSky API key (it can be read from environment variable ONESKY_PUBLIC_KEY)
  -c, --prettier [OPTIONAL] Path for the prettier config

Generate translation keys

Usage: onekey generate [options]

Options:

  -i, --input    Path for the json translations to read from
  -l, --locale   [OPTIONAL] Default locale to use (en-GB by default)
  -c, --prettier [OPTIONAL] Path for the prettier config

Generated output

This will generate a TypeScript type union with all the possible translation keys for your jsons (appended with the namespace that comes from the name of the file).

So if your translation files look like this

// main.json
{
  "hello": "Hello, friend",
  "friendly_hello": "Hello, {{name}}",
  "goodbye": "See you soon!",
}
// errors.json
{
  "hello": "Hello, seems there is a problem here!",
  "unknown": "I don't know what happened, but looks bad!",
}

Generate will give you something closer to this:

type TranslationKeyWithoutOptions =
  | 'main:hello'
  | 'main:goodbye'
  | 'errors:hello'
  | 'errors:unknown';
type TranslationWithOptions = {
  'main:friendly_hello': { name: string };
};
type TranslationKeyWithOptions = keyof TranslationWithOptions;

export type TranslationKey =
  | TranslationKeyWithoutOptions
  | TranslationKeyWithOptions;

FAQs

Package last updated on 15 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc