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

deepl-localize

v3.0.0

Published

Translation for $localize files with deepl

Downloads

43

Readme

deepl $localize / compiled-i18n tranlate

This tool uses deepl to translate all extracted languages by either angular/localize or compiled-i18n.

About

What is deepl?

DeepL is a machine translation company that offers neural machine translation services. Neural machine translation (NMT) is a type of machine translation that uses artificial neural networks to improve the accuracy and fluency of translations. DeepL is known for its high-quality translations and is considered one of the leading providers in the field of machine translation.

DeepL's most well-known product is the DeepL Translator, which allows users to translate text and documents between multiple languages. It supports a wide range of languages and is often praised for its ability to produce translations that are more natural and contextually accurate compared to traditional rule-based machine translation systems.

See deepl

What is $localize?

The $localize function is part of the Angular framework, which is a popular open-source JavaScript framework for building web and mobile applications. It is specifically used for internationalization (i18n) and localization (l10n) purposes within Angular applications.

The $localize function is used to mark and translate text within an Angular application. It allows developers to define messages in different languages and provides a way to extract those messages for translation. Here's how it typically works:

  1. Developers use the $localize function to mark text in their Angular templates and components that need to be translated. For example:
const message = $localize`Hello, World!`;
  1. After marking the text, developers can use Angular's localization tools to extract these marked messages into a translation file.
  2. Translators can then provide translations for the marked messages in various languages.
  3. When the application runs, Angular will use the appropriate translation based on the user's language preference or the selected language.

Keep in mind that Angular's internationalization and localization features, including $localize, may evolve over time, so it's a good practice to refer to the official Angular documentation or resources for the most up-to-date information on how to use these features in your Angular applications.

Localize perfectly works with other frameworks as well. See Miško's approach for qwik.

What is compiled-i18n?

The package compiled-i18n is a vite-plugin to solve localization on build time. This means the extraction is integrated on top of vite's build process and will be directly there if the build server is running.

The integration is much simpler, because you don't need to set it up, you only have to call a function to set the locale. The translation files look very similar to $localize files.

Per default it's translation function is exported as _ and looks like this in the code:

import {_} from 'compiled-i18n'
const message = _`Hello, World!`;

On top compiled-i18n is doing pluralization without adding a different api.

Installation

npm install deepl-localize -D

or

yarn add deepl-localize -D

Of course you can use it with npx as well.

npx deepl-localize translate -b your/path/en-US.json -l de-DE fr-FR -i de-DE -a "YOUR-DEEPL-API-KEY"

Translation

Usage

deepl-localize translate -b your/path/en-US.json -l de-DE fr-FR -i de-DE -a "YOUR-DEEPL-API-KEY"

Options:

| Command | Description | | ---------------------------------- | ------------------------------------------------------------------------------------------------------------- | | -a,--api-key | The deepl api key. If none is given, the environment variable DEEPL_API_KEY is used. | | -v, --version | output the version number | | -b, --base | The base file path. | | -o, --output | The output folder path. If none is given, the base folder is used. | | -c, --compiled-i18n | Tell the script you use compiled-i18n instead of $localize | | -l, --locales [value...] | Locales to translate to. For example de-DE fr-FR. If none is given, no translation will happen. (default: []) | | -i, --informal-locales [value...] | Locales to translate less formal. For example de-DE will use du instead of sie. (default: []) | | -h, --help | display help for command |

Stale

Usage

deepl-localize remove-stale -b your/path/en-US.json -l de-DE fr-FR

Options:

| Command | Description | | ------------------------- | ------------------------------------------------------------------------------------------------------------- | | -v, --version | output the version number | | -b, --base | The base file path. | | -o, --output | The output folder path. If none is given, the base folder is used. | | -c, --compiled-i18n | Tell the script you use compiled-i18n instead of $localize | | -l, --locales [value...] | Locales to translate to. For example de-DE fr-FR. If none is given, no translation will happen. (default: []) | | -d,--dry-run | Just show the stale translations. The script will not remove and just show them. (default: false) | | -h, --help | display help for command |