3.0.1 • Published 1 month ago

deepl-localize v3.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 month ago

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:

CommandDescription
-a,--api-key The deepl api key. If none is given, the environment variable DEEPL_API_KEY is used.
-v, --versionoutput 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-i18nTell 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, --helpdisplay help for command

Stale

Usage

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

Options:

CommandDescription
-v, --versionoutput 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-i18nTell 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-runJust show the stale translations. The script will not remove and just show them. (default: false)
-h, --helpdisplay help for command
3.0.1

1 month ago

2.0.4

5 months ago

3.0.0

5 months ago

2.0.3

1 year ago

2.0.2

1 year ago

2.0.1

1 year ago

2.0.0

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago

0.0.1

1 year ago