New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

dfx-translate

Package Overview
Dependencies
Maintainers
2
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dfx-translate - npm Package Compare versions

Comparing version 1.0.3 to 1.0.4

2

lib/translate.service.d.ts
import { HttpClient } from '@angular/common/http';
import { TranslateConfig } from "./translate.config";
import { TranslateConfig } from './translate.config';
import * as i0 from "@angular/core";

@@ -4,0 +4,0 @@ export declare class TranslateService {

{
"name": "dfx-translate",
"version": "1.0.3",
"version": "1.0.4",
"private": false,

@@ -26,7 +26,7 @@ "license": "MIT",

"bugs": {
"url": "https://gitlab.com/DatePoll/common/dfx-translate/-/issues"
"url": "https://gitlab.com/DatePoll/common/dfx-common/-/issues"
},
"repository": {
"type": "git",
"url": "git+https://gitlab.com/DatePoll/common/dfx-translate.git"
"url": "git+https://gitlab.com/DatePoll/common/dfx-common.git"
},

@@ -37,3 +37,3 @@ "peerDependencies": {

"rxjs": "2 - 7",
"node-fetch": "^2.6.6"
"node-fetch": "2 - 3"
},

@@ -40,0 +40,0 @@ "module": "fesm2015/dfx-translate.mjs",

# dfx-translate
A simple translation package for Angular 4 - 12.

@@ -7,8 +8,10 @@

### Features
* inline html translations with pipelines
* in-code translation with services
* an easy-to-use json structure
* auto-translation feature via [LibreTranslate](https://github.com/LibreTranslate/LibreTranslate) API integration
- inline html translations with pipelines
- in-code translation with services
- an easy-to-use json structure
- auto-translation feature via [LibreTranslate](https://github.com/LibreTranslate/LibreTranslate) API integration
### Information
- [Supported languages for auto-translation](#supported-languages)

@@ -19,6 +22,8 @@ - [Development notes](#development)

- created with [Angular](https://angular.io)
, [used libraries](https://gitlab.com/DatePoll/common/dfx-translate/-/blob/master/package.json)
, [used libraries](https://gitlab.com/DatePoll/common/dfx-common/-/blob/develop/package.json)
## Setup
### Installation
```bash

@@ -29,3 +34,5 @@ npm install dfx-translate@latest

### Language file setup
Language files **must** be saved in `src/assets/i18n/LANGUAGE_CODE.json`; Create the directory if it does not exist.
```bash

@@ -36,2 +43,3 @@ mkdir -p ./src/assets/i18n

Choose a primary language, lets say you've picked **english**. Create an `en.json` file with following content:
```json

@@ -43,6 +51,9 @@ {

```
Note: The json structure must always consist of a key and value pair.
#### Manual translation
Choose an additional language, lets say you've picked **german**. Create an `de.json` file
```json

@@ -54,2 +65,3 @@ {

```
Note: You **do not** have to translate all strings if you are using

@@ -59,2 +71,3 @@ the [auto-translate feature](#auto-deep-learning-translation).

#### Auto translation
dfx-translate can translate the primary language into a whole new language and will take partially manual translated

@@ -67,3 +80,5 @@ languages into account, meaning it will only translate strings which are not occurring in the manual created files

### Registration in root (app) module
This has to be done only once in the project. Ideal in `app.module.ts`
```typescript

@@ -88,8 +103,10 @@ import {DfxTranslateModule} from "dfx-translate";

```
property | description | default value
--- | --- | ---
defaultLanguage | Short code of the primary language (identically to the file name) | `en`
useLocalStorage | Saves selected languages as the preference into local storage | `true`
| property | description | default value |
| --------------- | ----------------------------------------------------------------- | ------------- |
| defaultLanguage | Short code of the primary language (identically to the file name) | `en` |
| useLocalStorage | Saves selected languages as the preference into local storage | `true` |
### Registration in feature module
```typescript

@@ -110,6 +127,9 @@ import {DfxTranslateModule} from "dfx-translate";

## Usage
### Switching languages
Language switching is as easy as one function call.
Note: The language code used has to exist as `src/assets/i18n/LANGUAGE_CODE.json`
```typescript

@@ -134,3 +154,5 @@ import {TranslateService} from "dfx-translate";

### Pipeline usage
Import `DfxTranslateModule` into the module requiring the translation pipe.
```typescript

@@ -153,2 +175,3 @@ import {DfxTranslateModule} from "dfx-translate";

Now you can use it with `tr` in html
```angular2html

@@ -160,3 +183,5 @@ <h1>{{'WELCOME' | tr}}</h1>

### Service usage
Access translations via code with `TranslateService`
```typescript

@@ -181,2 +206,3 @@ import {TranslateService} from "dfx-translate";

## Auto deep learning translation
It's possible to translate not manual translated strings via

@@ -191,24 +217,27 @@ [LibreTranslate](https://github.com/LibreTranslate/LibreTranslate) API. LibreTranslate is an open-source, self-hostable

Command syntax:
```bash
node ./node_modules/dfx-translate/translation/generateTranslation.js {API_URL} {SOURCE_LANGUAGE_CODE} {TARGET_LANGUAGE_CODE}
```
Note: You **never** have to auto-translate fully manual translated files
### Supported languages
LANGUAGE_CODE | name
--- | ---
en | English
ar | Arabic
zh | Chinese
fr | French
de | German
hi | Hindi
ga | Irish
it | Italian
ja | Japanese
ko | Korean
pt | Portuguese
ru | Russian
es | Spanish
| LANGUAGE_CODE | name |
| ------------- | ---------- |
| en | English |
| ar | Arabic |
| zh | Chinese |
| fr | French |
| de | German |
| hi | Hindi |
| ga | Irish |
| it | Italian |
| ja | Japanese |
| ko | Korean |
| pt | Portuguese |
| ru | Russian |
| es | Spanish |
Note: Keep in mind that at least one of the fully manual translated files has to be in such a language for this feature

@@ -218,3 +247,4 @@ to work.

### Example
* **Primary language: en**; **Fully translated language: de**; **Partially translated language: es**; **Not translated
- **Primary language: en**; **Fully translated language: de**; **Partially translated language: es**; **Not translated
language: fr**

@@ -226,9 +256,10 @@ ```bash

Following files should be in `src/assets/i18n/` folder.
* `en.json` - the primary language
* `de.json` - additional language, fully manual translated
* `es.json` - additional language, partially manual translated
* `es_auto.json` - additional language, auto-translated missing strings of `es.json` compared to the primary language
* `fr_auto.json` - additional language, completely auto-translated containing all translations
- `en.json` - the primary language
- `de.json` - additional language, fully manual translated
- `es.json` - additional language, partially manual translated
- `es_auto.json` - additional language, auto-translated missing strings of `es.json` compared to the primary language
- `fr_auto.json` - additional language, completely auto-translated containing all translations
### Simplifying
For simplicity purposes I wrote a little shell script. Put this at the top / root level of the project

@@ -252,5 +283,7 @@

```
Now you only have to run this script.
## Development
Everything important in this library is located in `projects/dfx-translate`, that's the "real" library. (following

@@ -260,2 +293,3 @@ commands still have to be executed at the root level)

### Dependency installation
```bash

@@ -266,2 +300,3 @@ npm install

### Starting in development environment
```bash

@@ -272,2 +307,3 @@ npm run-script watch

### Building a production version
```bash

@@ -278,4 +314,5 @@ npm run-script build

## Deployment notes
dfx-translate deployments are managed
via [.gitlab-ci](https://gitlab.com/DatePoll/common/dfx-translate/-/blob/development/.gitlab-ci.yml)
via [.gitlab-ci](https://gitlab.com/DatePoll/common/dfx-common/-/blob/development/.gitlab-ci.yml)

@@ -286,8 +323,10 @@ All builds are uploaded

### Development builds
Commits to the [development](https://gitlab.com/DatePoll/common/dfx-translate/-/tree/development) branch create a dev
Commits to the [development](https://gitlab.com/DatePoll/common/dfx-common/-/tree/develop) branch create a dev
build downloadable via [this link](https://releases.datepoll.org/common/dfx-translate/dfx-translate-dev.zip).
### Production builds
Tags create a release build downloadable
via [this link](https://releases.datepoll.org/common/dfx-translate/dfx-translate-latest.zip). Additionally, a versioned
zip is uploaded and the package is published to [npm](https://www.npmjs.com/package/dfx-translate).

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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