Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(backend): Add missing content for i18n plugin file when using AI #636

Merged
merged 1 commit into from
Jan 6, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ export class TranslateAiLanguagesAdminService {
return;
}

const pluginPath = join(
ABSOLUTE_PATHS.plugin({ code: plugin.code }).frontend.languages,
`${code}.json`,
);

const textLang = JSON.parse(await readFile(langPath, 'utf-8'));
const { text } = await generateText({
model,
Expand All @@ -88,9 +93,16 @@ export class TranslateAiLanguagesAdminService {

Important: Skip translation if is already translated (and not identical to source).

Source content (en):
Source content (DEFAULT) (en):
${JSON.stringify(textLang, null, 2)}

${
existsSync(pluginPath)
? `Current content for (${code}):
${JSON.stringify(pluginPath, null, 2)}`
: ''
}

Return the same content with identical structure after translation.
`,
});
Expand Down
Loading