Skip to content

Commit

Permalink
chore: update README and logic when saving generated file
Browse files Browse the repository at this point in the history
  • Loading branch information
gabriel-logan committed Jun 2, 2024
1 parent 427a60e commit bbd4b26
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 12 deletions.
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ const jsonFile = {
Now, you can use the library to translate the JSON file into multiple languages:

```javascript
const { translateToMultipleFolders, translateToUnicFolder } = require('azure-translator-code');
const { translateToMultipleFolders, translateToUnicFolder, updateTranslationsMulti, updateTranslationsUnic } = require('azure-translator-code');
```
or
```javascript
import { translateToMultipleFolders, translateToUnicFolder } from 'azure-translator-code';
import { translateToMultipleFolders, translateToUnicFolder, updateTranslationsMulti, updateTranslationsUnic } from 'azure-translator-code';
```

```javascript
Expand Down Expand Up @@ -101,16 +101,20 @@ const jsonFile = {
};

// Translation to multiple folders
translateToMultipleFolders(key, endpoint, location, fromLang, toLangs, jsonFile);
translateToMultipleFolders(key, endpoint, location, fromLang, toLangs, jsonFile); // Replace all values ​​and keys
// This function will return a folder called multiFolderGeneratedTranslations

// Translation to a single folder
translateToUnicFolder(key, endpoint, location, fromLang, toLangs, jsonFile);
translateToUnicFolder(key, endpoint, location, fromLang, toLangs, jsonFile); // Replace all values ​​and keys
// This function will return a folder called unicFolderGeneratedTranslations

// Update translation from the multiple folders
updateTranslationsMulti(key, endpoint, location, fromLang, toLangs, jsonFile);
updateTranslationsMulti(key, endpoint, location, fromLang, toLangs, jsonFile); // Only new keys will be translated (Optimized)
// This function will update the translations in the folder called multiFolderGeneratedTranslations

// Update translation from the single folder
updateTranslationsUnic(key, endpoint, location, fromLang, toLangs, jsonFile); // Only new keys will be translated (Optimized)
// This function will update the translations in the folder called unicFolderGeneratedTranslations
```

#### You can also choose the folder or folder name where you will save the files.
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "azure-translator-code",
"version": "1.1.3",
"version": "1.1.4",
"description": "Azure Cognitive Services Translator Text API Code for Use with Common Languages",
"author": {
"name": "Gabriel Logan"
Expand Down
2 changes: 1 addition & 1 deletion src/translateToMultipleFolders/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export default function translateToMultipleFolders(
jsonFile: TranslationType,
folderNamePath: string = 'multiFolderGeneratedTranslations', // Onde sera salvo os arquivos
): void {
const traducoesDir: string = path.join(__dirname, '..', '..', '..', '..', folderNamePath);
const traducoesDir: string = path.join(process.cwd(), folderNamePath);

if (!fs.existsSync(traducoesDir)) {
fs.mkdirSync(traducoesDir, { recursive: true }); // Use { recursive: true } para criar pastas recursivamente, se necessário
Expand Down
2 changes: 1 addition & 1 deletion src/translateToUnicFolder/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export default function translateToUnicFolder(
jsonFile: TranslationType,
folderNamePath: string = 'unicFolderGeneratedTranslations', // Onde sera salvo os arquivos
): void {
const traducoesDir: string = path.join(__dirname, '..', '..', '..', '..', folderNamePath);
const traducoesDir: string = path.join(process.cwd(), folderNamePath);

if (!fs.existsSync(traducoesDir)) {
fs.mkdirSync(traducoesDir, { recursive: true }); // Use { recursive: true } para criar pastas recursivamente, se necessário
Expand Down
2 changes: 1 addition & 1 deletion src/updateTranslationMulti/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export default function updateTranslationsMulti(
jsonFile: TranslationType,
folderNamePath: string = 'multiFolderGeneratedTranslations', // Onde sera salvo os arquivos
): void {
const traducoesDir: string = path.join(__dirname, '..', '..', '..', '..', folderNamePath);
const traducoesDir: string = path.join(process.cwd(), folderNamePath);

if (!fs.existsSync(traducoesDir)) {
fs.mkdirSync(traducoesDir, { recursive: true });
Expand Down
2 changes: 1 addition & 1 deletion src/updateTranslationUnic/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export default function updateTranslationsUnic(
jsonFile: TranslationType,
folderNamePath: string = 'unicFolderGeneratedTranslations', // Onde sera salvo os arquivos
): void {
const traducoesDir: string = path.join(__dirname, '..', '..', '..', '..', folderNamePath);
const traducoesDir: string = path.join(process.cwd(), folderNamePath);

if (!fs.existsSync(traducoesDir)) {
fs.mkdirSync(traducoesDir, { recursive: true });
Expand Down

0 comments on commit bbd4b26

Please sign in to comment.