Skip to content

Save translated files to sub-directory is not working in windows. #73

@andreas-stumpf-conxepta

Description

Hello Dejan,

I noticed that i18n-auto-translation saves the output file into the working directory on Windows instead of the source folder / dirPath.

Currently in translate.ts (line 65), the code is:

this.saveTo = path.join(
  filePath.substring(0, filePath.lastIndexOf('/')),
  `${argv.to}.json`,
);

This works on Linux but not on Windows.
To support both Linux and Windows paths, you can change it to:

this.saveTo = path.join(
  filePath.replace(/[\\/][^\\/]*$/, ''), 
  `${argv.to}.json`,
);

I have forked your repo to add an Azure OpenAI provider and included this fix.
See my initial commit here: Commit.

Adding the provider worked like a charm! 🚀

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions