Rspress plugin for translating files using LLM, currently only supports GPT.
When you start the project, the plugin will automatically translate the files in the source language folder under your document root directory into the target language and save them in the target language folder.
For files in the source language folder that do not need to be translated, they will also be automatically copied to the target language folder every time you start the project.
Note that the plugin will do a hash cache
on the files in the source language folder every time you start the project. If it finds updates compared to the previous cache
, it will re-translate the files, otherwise it will skip the files.
Object
ClientOptions {}
Client settings for calling OpenAI, including API-KEY, Agent, etc. For details, you can go to Type Declarations to see all supported parameters.
string
gpt-3.5-turbo
The name of the model used to call OpenAI. You can go to the Model List to see all supported model names.
Object
Customize the configuration for matching files that need to be translated.
string[]
[]
Exclude certain files from translation. For example:
Note: The strings in the array support glob patterns.
string[]
[]
The file extensions of files included in the translation process. By default, Rspress includes all 'md'
, 'mdx'
files in the routes. If you want to customize the extensions, you can use this option. For example:
Number
3
Rate limit for the large model, default is 3 requests per minute.
Function
Prompt function for the large model, which takes three parameters: content (content of the source language file), from (name of the source language), and to (name of the target language). The return value of this function will be used as the prompt parameter passed to the large model. For example: