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

@plastichub/osr-i18n

v0.2.5

Published

Currently translates Markdown directories using [DeepL](deepl.com) API.

Downloads

83

Readme

i18n related library and CLI for OSR content

Currently translates Markdown directories using DeepL API.

Installation

  1. Install from NPM
  npm i -g @plastichub/osr-i18n
  1. Define an environment variable on your system OSR-CONFIG which holds the path to a json file, eg: C:\Users\nobody-likeyou\.osr\config.json with the following content (see ./docs/config.json example):
{
  "deepl": {
    "comment": "Please get a key on deepl.com ! ",
    "auth_key": "34dbf59f-adeb-1959-d906-502e0ec6afb7",
    "free_api": false
  }
}

You can verify the config by osr-i18n info

Commands

info

Brief: outputs configuration and supported language keys

  osr-i18n info

translate

Simple


osr-i18n translate --text="Na Du Schnecke" --sourceLang="DE" --targetLang="EN"

# or pipe into a file

osr-i18n translate --text="Na Du Schnecke" --sourceLang="DE" --targetLang="EN" > translations.json


```json
Translating Na Du Schnecke! Du schaust so traurig aus! to 
[
  {
    detected_source_language: 'DE',
    text: 'Well you snail! You look so sad!'
  }
]

Using Glob patters

1. Translate directory of files, simple


osr-i18n translate --src="./**/*.md" --sourceLang="DE" --targetLang="EN"

Remarks:

  • this will translate all files in ./**/*.md, to ./**/somefile.EN.md

  • when no --dst argument is specified, the output path is composed by adding the target language in the filename, eg: my-info.md becomes my-info_de.md

  • please run osr-i18n translate --help for supported file types

2. Translate directory of files, advanced


osr-i18n translate --src="./**/*.md" --dst='${SRC_DIR}/${SRC_NAME}.${DST_LANG}.+(md)' --sourceLang="DE" --targetLang="EN"

2. Translate directory of files, advanced


osr-i18n translate --src="./**/*.md" --cwd='source directory' --dst='target directory' --sourceLang="DE" --targetLang="EN"

Remarks:

  • sourceLang is not needed to be set explicit, DeepL will recognize
  • please run osr-i18n translate --help for supported file types
  • See more examples in ./tests/
  • Please see more integration examples in ./docs/Integration.md

Example : Create a glossary


osr-i18n glossary create --name="pp" --src="${OSR_ROOT}/osr-commons/i18n/glossary/en/de/*.csv" --srcLang="EN" --dstLang="DE"

Remarks:

This creates a glossary file, given a CSV file, eg:

Plastic,Kunststoff
Shredder,Granulator
Mould,Spritzgussform
Precious – Plastic,Precious - Plastic
Sheetpress,Plattenpresse
Injection,Spritzgießmaschine
Injection Kits,Injection Kits 

It creates a meta file, adding '_glossary.json' to the source CSV file, with the content:

{
  "glossaryId": "60c0b19b-27f0-45ab-a375-feaef2b85b92",
  "name": "pp",
  "ready": true,
  "sourceLang": "en",
  "targetLang": "de",
  "creationTime": "2023-02-18T17:25:37.800Z",
  "entryCount": 7
}

Path variables

  • DST_LANG: Destination language
  • SRC_LANG: Destination language
  • CWD: Current working directory, as specified on the CLI
  • SRC_REL: Relative directory, from main source path to currently translated file

Todos

  • [x] Support Glossaries
  • [x] Plugins: emoji fuckery removal, ignore filter/patterns
  • [-] Imprint meta (osr-version, config)
  • [x] XLS (osr-lib-data)
  • [-] Google Sheets, direct
  • [-] Google Speech API to produce audio files (see boilerplate in ./src/speech/google.ts)
  • [-] Audio (from osr-ai/chatgpt)
  • [-] translate keys in unitconv
  • [-] OSRL AST
  • [x] JSON values, via JSON-get|path

References

LLMs