Skip to content

Commit

Permalink
Merge pull request #59 from while1618/module
Browse files Browse the repository at this point in the history
  • Loading branch information
while1618 authored Jan 24, 2025
2 parents cd5c7ed + 4f76ca2 commit 62bd560
Show file tree
Hide file tree
Showing 16 changed files with 57 additions and 56 deletions.
2 changes: 1 addition & 1 deletion .prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
export default {
singleQuote: true,
printWidth: 100,
endOfLine: 'auto',
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "i18n-auto-translation",
"version": "1.11.0",
"type": "module",
"description": "Auto translate i18n JSON file(s) to desired language(s).",
"main": "dist/index.js",
"license": "MIT",
Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env node
import { argv } from './translate/cli';
import { TranslateSupplier } from './translate/translate-supplier';
import { argv } from './translate/cli.js';
import { TranslateSupplier } from './translate/translate-supplier.js';

TranslateSupplier.getProvider(argv.apiProvider)
.translate()
Expand Down
8 changes: 4 additions & 4 deletions src/translate/providers/azure-official-api.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import axios, { AxiosRequestConfig } from 'axios';
import crypto from 'crypto';
import { decode, encode } from 'html-entities';
import { argv } from '../cli';
import { AzureTranslateResponse } from '../payload';
import { Translate } from '../translate';
import { addCustomCert } from '../util';
import { argv } from '../cli.js';
import { AzureTranslateResponse } from '../payload.js';
import { Translate } from '../translate.js';
import { addCustomCert } from '../util.js';

export class AzureOfficialAPI extends Translate {
private static readonly endpoint: string = 'api.cognitive.microsofttranslator.com';
Expand Down
8 changes: 4 additions & 4 deletions src/translate/providers/azure-rapid-api.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import axios, { AxiosRequestConfig } from 'axios';
import crypto from 'crypto';
import { decode, encode } from 'html-entities';
import { argv } from '../cli';
import { AzureTranslateResponse } from '../payload';
import { Translate } from '../translate';
import { addCustomCert } from '../util';
import { argv } from '../cli.js';
import { AzureTranslateResponse } from '../payload.js';
import { Translate } from '../translate.js';
import { addCustomCert } from '../util.js';

export class AzureRapidAPI extends Translate {
private static readonly endpoint: string = 'microsoft-translator-text-api3.p.rapidapi.com';
Expand Down
8 changes: 4 additions & 4 deletions src/translate/providers/deep-rapid-api.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import axios, { AxiosRequestConfig } from 'axios';
import { decode, encode } from 'html-entities';
import { argv } from '../cli';
import { DeepTranslateResponse } from '../payload';
import { Translate } from '../translate';
import { addCustomCert } from '../util';
import { argv } from '../cli.js';
import { DeepTranslateResponse } from '../payload.js';
import { Translate } from '../translate.js';
import { addCustomCert } from '../util.js';

export class DeepRapidAPI extends Translate {
private static readonly endpoint: string = 'deep-translate1.p.rapidapi.com';
Expand Down
8 changes: 4 additions & 4 deletions src/translate/providers/deepl-free-api.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import axios, { AxiosRequestConfig } from 'axios';
import { decode, encode } from 'html-entities';
import { argv } from '../cli';
import { DeepLTranslateResponse } from '../payload';
import { Translate } from '../translate';
import { addCustomCert } from '../util';
import { argv } from '../cli.js';
import { DeepLTranslateResponse } from '../payload.js';
import { Translate } from '../translate.js';
import { addCustomCert } from '../util.js';

export class DeepLFreeAPI extends Translate {
private static readonly endpoint: string = 'api-free.deepl.com';
Expand Down
8 changes: 4 additions & 4 deletions src/translate/providers/deepl-pro-api.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import axios, { AxiosRequestConfig } from 'axios';
import { decode, encode } from 'html-entities';
import { argv } from '../cli';
import { DeepLTranslateResponse } from '../payload';
import { Translate } from '../translate';
import { addCustomCert } from '../util';
import { argv } from '../cli.js';
import { DeepLTranslateResponse } from '../payload.js';
import { Translate } from '../translate.js';
import { addCustomCert } from '../util.js';

export class DeepLProAPI extends Translate {
private static readonly endpoint: string = 'api.deepl.com';
Expand Down
6 changes: 3 additions & 3 deletions src/translate/providers/google-official-api.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Translate as GoogleTranslate } from '@google-cloud/translate/build/src/v2';
import { Translate as GoogleTranslate } from '@google-cloud/translate/build/src/v2/index.js';
import { decode, encode } from 'html-entities';
import { argv } from '../cli';
import { Translate } from '../translate';
import { argv } from '../cli.js';
import { Translate } from '../translate.js';

export class GoogleOfficialAPI extends Translate {
protected callTranslateAPI = async (valuesForTranslation: string[]): Promise<string> => {
Expand Down
8 changes: 4 additions & 4 deletions src/translate/providers/lecto-rapid-api.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import axios, { AxiosRequestConfig } from 'axios';
import { decode, encode } from 'html-entities';
import { argv } from '../cli';
import { LectoTranslateResponse } from '../payload';
import { Translate } from '../translate';
import { addCustomCert } from '../util';
import { argv } from '../cli.js';
import { LectoTranslateResponse } from '../payload.js';
import { Translate } from '../translate.js';
import { addCustomCert } from '../util.js';

export class LectoRapidAPI extends Translate {
private static readonly endpoint: string = 'lecto-translation.p.rapidapi.com';
Expand Down
8 changes: 4 additions & 4 deletions src/translate/providers/lingvanex-rapid-api.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import axios, { AxiosRequestConfig } from 'axios';
import { decode, encode } from 'html-entities';
import { argv } from '../cli';
import { LingvanexTranslateResponse } from '../payload';
import { Translate } from '../translate';
import { addCustomCert } from '../util';
import { argv } from '../cli.js';
import { LingvanexTranslateResponse } from '../payload.js';
import { Translate } from '../translate.js';
import { addCustomCert } from '../util.js';

export class LingvanexRapidAPI extends Translate {
private static readonly endpoint: string = 'lingvanex-translate.p.rapidapi.com';
Expand Down
8 changes: 4 additions & 4 deletions src/translate/providers/nlp-rapid-api.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import axios, { AxiosRequestConfig } from 'axios';
import { decode, encode } from 'html-entities';
import { argv } from '../cli';
import { NLPTranslateResponse } from '../payload';
import { Translate } from '../translate';
import { addCustomCert } from '../util';
import { argv } from '../cli.js';
import { NLPTranslateResponse } from '../payload.js';
import { Translate } from '../translate.js';
import { addCustomCert } from '../util.js';

export class NLPRapidAPI extends Translate {
private static readonly endpoint: string = 'nlp-translation.p.rapidapi.com';
Expand Down
20 changes: 10 additions & 10 deletions src/translate/translate-supplier.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { AzureOfficialAPI } from './providers/azure-official-api';
import { AzureRapidAPI } from './providers/azure-rapid-api';
import { DeepRapidAPI } from './providers/deep-rapid-api';
import { DeepLFreeAPI } from './providers/deepl-free-api';
import { DeepLProAPI } from './providers/deepl-pro-api';
import { GoogleOfficialAPI } from './providers/google-official-api';
import { LectoRapidAPI } from './providers/lecto-rapid-api';
import { LingvanexRapidAPI } from './providers/lingvanex-rapid-api';
import { NLPRapidAPI } from './providers/nlp-rapid-api';
import { Translate } from './translate';
import { AzureOfficialAPI } from './providers/azure-official-api.js';
import { AzureRapidAPI } from './providers/azure-rapid-api.js';
import { DeepRapidAPI } from './providers/deep-rapid-api.js';
import { DeepLFreeAPI } from './providers/deepl-free-api.js';
import { DeepLProAPI } from './providers/deepl-pro-api.js';
import { GoogleOfficialAPI } from './providers/google-official-api.js';
import { LectoRapidAPI } from './providers/lecto-rapid-api.js';
import { LingvanexRapidAPI } from './providers/lingvanex-rapid-api.js';
import { NLPRapidAPI } from './providers/nlp-rapid-api.js';
import { Translate } from './translate.js';

interface Providers {
'google-official': GoogleOfficialAPI;
Expand Down
6 changes: 3 additions & 3 deletions src/translate/translate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { globSync } from 'glob';
import extend from 'just-extend';
import path from 'path';
import yoctoSpinner from 'yocto-spinner';
import { argv } from './cli';
import { JSONObj } from './payload';
import { delay, replaceAll } from './util';
import { argv } from './cli.js';
import { type JSONObj } from './payload.js';
import { delay, replaceAll } from './util.js';

export abstract class Translate {
public static readonly sentenceDelimiter: string = '\n#__#\n';
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */

/* Language and Environment */
"target": "ES2021" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
"target": "es2022" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
// "jsx": "preserve", /* Specify what JSX code is generated. */
// "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
Expand All @@ -24,7 +24,7 @@
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */

/* Modules */
"module": "CommonJS" /* Specify what module code is generated. */,
"module": "es2022" /* Specify what module code is generated. */,
// "rootDir": "./", /* Specify the root folder within your source files. */
"moduleResolution": "Node" /* Specify how TypeScript looks up a file from a given module specifier. */,
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
Expand Down

0 comments on commit 62bd560

Please sign in to comment.