Internationalization Handling

Kecare can use AI to translate your articles into multiple languages, enabling your content to reach a multilingual readership.

Enable Translation

Using translation in Kecare is also very simple. Just add the translate field to the Front Matter of the article you want to translate:

---
title: 我的第一篇文章
translate: ['zh-CN', 'en-US', 'ja-JP']
---

The first language code must be the original language of the article.

Configure Translation Service

In the .kecare directory, create a new kecare.config.ts file.

Then configure LLM in .kecare/kecare.config.ts:

export async function kecareConfig() {
    return {
        llm: {
            model: 'deepseek-chat',
            apiKey: 'your-api-key',
            apiBaseUrl: 'https://api.deepseek.com/v1',
            prompt: ''  // 提示词
        }
    };
}

Supports any service compatible with the OpenAI API format.

Common Language Codes

Language Code
Simplified Chinese zh-CN
English en-US
Japanese ja-JP
Korean ko-KR
Traditional Chinese zh-TW

Language codes follow the BCP 47 standard: language-region (e.g., en-GB, pt-BR).

Caching and Incremental Updates

The translation results are cached in the .kecare/.tmp directory, and only modified parts will be translated during the next build to maximize token cost savings.

To clear the cache, simply delete the .tmp directory.

文章作者:
文章链接:kecare.me/articles/493f5fa2
版权声明: 博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来源