зеркало из https://github.com/mozilla/pontoon.git
Fix LLM machinery source issue in database (#3230)
This commit is contained in:
Родитель
890be4a534
Коммит
071829c820
|
@ -22,7 +22,7 @@ import {
|
|||
import { updateResource } from '~/modules/resource/actions';
|
||||
import { updateStats } from '~/modules/stats/actions';
|
||||
import { useAppDispatch, useAppSelector } from '~/hooks';
|
||||
import { serializeEntry } from '~/utils/message';
|
||||
import { serializeEntry, getPlainMessage } from '~/utils/message';
|
||||
|
||||
/**
|
||||
* Return a function to send a translation to the server.
|
||||
|
@ -53,8 +53,9 @@ export function useSendTranslation(): (ignoreWarnings?: boolean) => void {
|
|||
setEditorBusy(true);
|
||||
|
||||
const translation = serializeEntry(entity.format, entry);
|
||||
const normalizedTranslation = getPlainMessage(translation, entity.format);
|
||||
const sources =
|
||||
machinery && machinery.translation === translation
|
||||
machinery && machinery.translation === normalizedTranslation
|
||||
? machinery.sources
|
||||
: [];
|
||||
const content = await createTranslation(
|
||||
|
|
|
@ -2,7 +2,7 @@ import { Localized } from '@fluent/react';
|
|||
import classNames from 'classnames';
|
||||
import React, { useCallback, useContext, useEffect, useRef } from 'react';
|
||||
|
||||
import type { MachineryTranslation } from '~/api/machinery';
|
||||
import type { MachineryTranslation, SourceType } from '~/api/machinery';
|
||||
import { logUXAction } from '~/api/uxaction';
|
||||
import { EditorActions } from '~/context/Editor';
|
||||
import { HelperSelection } from '~/context/HelperSelection';
|
||||
|
@ -45,7 +45,10 @@ export function MachineryTranslationComponent({
|
|||
if (window.getSelection()?.isCollapsed !== false) {
|
||||
setElement(index);
|
||||
const content = llmTranslation || translation.translation;
|
||||
setEditorFromHelpers(content, translation.sources, true);
|
||||
const sources: SourceType[] = llmTranslation
|
||||
? ['gpt-transform']
|
||||
: translation.sources;
|
||||
setEditorFromHelpers(content, sources, true);
|
||||
if (llmTranslation) {
|
||||
logUXAction('LLM Translation Copied', 'LLM Feature Adoption', {
|
||||
action: 'Copy LLM Translation',
|
||||
|
|
Загрузка…
Ссылка в новой задаче