Skip to content

Commit 1f30cf7

Browse files
committed
Add auto translation using llms
1 parent 574bdfa commit 1f30cf7

File tree

15 files changed

+419
-253
lines changed

15 files changed

+419
-253
lines changed

src/components/flow/exit/Exit.module.scss

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@
2929
border-bottom-right-radius: 0px !important;
3030
}
3131

32-
border-left: 1px solid darken($translation_bg, 5%);
33-
background: $translation_bg;
32+
3433

3534
.endpoint {
3635
position: relative;
@@ -50,7 +49,10 @@
5049
}
5150

5251
&.missing_localization {
52+
5353
color: $translation_missing;
54+
border-left: 1px solid darken($translation_bg, 5%);
55+
background: $translation_bg;
5456

5557
&:last-child {
5658
border-bottom-right-radius: $curvature;
@@ -90,9 +92,11 @@
9092
color: #fff;
9193
}
9294
}
95+
9396
.endpoint {
9497
background: $red !important;
9598
border-color: $red !important;
99+
96100
.confirm_x {
97101
color: white;
98102
position: absolute;
@@ -167,7 +171,7 @@
167171
text-align: left;
168172
padding: 8px 10px;
169173
border-top: 1px solid $light_gray;
170-
174+
171175
.operand {
172176
padding-top: 3px;
173177
font-size: 12px;
@@ -182,4 +186,4 @@
182186

183187
.confirm_x {
184188
color: white;
185-
}
189+
}

src/components/index.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ import {
3636
UpdateTranslationFilters,
3737
updateTranslationFilters,
3838
reset,
39-
Reset
39+
Reset,
40+
OnUpdateLocalizations,
41+
onUpdateLocalizations
4042
} from 'store/thunks';
4143
import { ACTIVITY_INTERVAL, downloadJSON, renderIf, onNextRender } from 'utils';
4244
import { PopTabType } from 'config/interfaces';
@@ -73,6 +75,7 @@ export interface FlowEditorStoreProps {
7375
scrollToAction: string;
7476
popped: string;
7577
updateTranslationFilters: UpdateTranslationFilters;
78+
onUpdateLocalizations: OnUpdateLocalizations;
7679
}
7780

7881
const hotStore = createStore();
@@ -281,6 +284,7 @@ export class FlowEditor extends React.Component<FlowEditorStoreProps> {
281284

282285
{renderIf(this.props.definition && this.props.translating && !this.props.fetchingFlow)(
283286
<TranslatorTab
287+
baseLanguage={this.props.baseLanguage}
284288
language={this.props.language}
285289
languages={this.props.languages ? this.props.languages.items : {}}
286290
localization={
@@ -291,6 +295,7 @@ export class FlowEditor extends React.Component<FlowEditorStoreProps> {
291295
onTranslationClicked={this.handleScrollToTranslation}
292296
onTranslationOpened={this.handleOpenTranslation}
293297
onTranslationFilterChanged={this.props.updateTranslationFilters}
298+
onUpdateLocalizations={this.props.onUpdateLocalizations}
294299
translationFilters={
295300
this.props.definition ? this.props.definition._ui.translation_filters : null
296301
}
@@ -373,6 +378,7 @@ const mapDispatchToProps = (dispatch: DispatchWithState) =>
373378
onOpenNodeEditor,
374379
handleLanguageChange,
375380
updateTranslationFilters,
381+
onUpdateLocalizations,
376382
reset
377383
},
378384
dispatch

src/components/nodeeditor/NodeEditor.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export class NodeEditor extends React.Component<NodeEditorProps> {
103103
}
104104

105105
private updateLocalizations(language: string, changes: LocalizationUpdates) {
106-
this.props.onUpdateLocalizations(language, changes);
106+
this.props.onUpdateLocalizations(language, false, changes);
107107
}
108108

109109
private removeLocalizations(uuid: string, keys?: string[]) {

src/components/translator/TranslatorTab.module.scss

Lines changed: 40 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
border-radius: 4px;
2929
transition: all 500ms ease-in-out;
3030
opacity: 1;
31+
3132
&.complete {
3233
opacity: 0;
3334
padding: 0px;
@@ -42,17 +43,21 @@
4243
background: $red;
4344
}
4445

46+
47+
4548
.options {
4649
background: #777;
4750
color: $light_gray_2;
4851
padding-top: 4px;
4952

5053
&.options_visible {
54+
padding-bottom: 4px;
55+
5156
.filters {
5257
height: 35px;
53-
padding: 6px;
5458
opacity: 1;
5559
padding-bottom: 0px;
60+
5661
.pct_complete {
5762
opacity: 1;
5863
}
@@ -65,25 +70,20 @@
6570
}
6671
}
6772

68-
&.change_visible {
69-
.changeLanguage {
70-
height: 20px;
71-
padding: 6px;
72-
opacity: 1;
73-
}
74-
}
75-
7673
&:hover {
7774
.header {
7875
.progress_bar {
7976
.filled {
8077
background: lighten($blue, 3%);
8178
}
79+
8280
&.hundredpct {
8381
background: lighten($lime, 3%);
8482
}
83+
8584
border: solid 1px rgba(100, 100, 100, 0.7);
8685
}
86+
8787
.toggle {
8888
color: $light_gray_2;
8989
}
@@ -130,35 +130,55 @@
130130
font-size: 12px;
131131
display: flex;
132132
flex-flow: wrap;
133+
align-items: center;
133134

134135
.pct_complete {
135136
font-size: 18px;
136137
align-self: center;
137-
margin-top: -6px;
138-
padding: 0px 4px;
138+
139+
padding: 0px 6px;
139140
opacity: 0;
140141
cursor: pointer;
141142
transition: opacity 600ms ease-in-out;
142143
}
144+
143145
.checkboxes {
144146
flex-grow: 1;
145-
> div:last-child {
146-
margin-top: 4px;
147-
}
147+
--checkbox-padding: 2px 6px;
148+
--checkbox-hover-bg: rgba(0, 0, 0, 0.1);
149+
--color-text: rgba(255, 255, 255, 0.8);
150+
148151
}
149152
}
150153

151-
.changeLanguage {
152-
height: 0px;
153-
opacity: 0;
154+
.buttons {
155+
display: flex;
154156

155157
button {
156-
background: #777;
158+
background: rgba(0, 0, 0, 0.1);
157159
color: $light_gray_2;
158-
border: solid 1px $light_gray_2;
160+
border: solid 1px rgba(255, 255, 255, 0.5);
159161
width: 100%;
162+
border-radius: var(--curvature);
163+
margin: 4px;
164+
padding: 2px 0px;
165+
}
166+
167+
button:hover {
168+
background: rgba(0, 0, 0, 0.2);
169+
cursor: pointer;
160170
}
161171
}
172+
173+
button.auto_translating {
174+
background: #fff;
175+
color: #777;
176+
}
177+
178+
button.auto_translating:hover {
179+
background: #fff;
180+
}
181+
162182
}
163183

164184
.translate_block {
@@ -236,4 +256,4 @@
236256
font-size: 10px;
237257
}
238258
}
239-
}
259+
}

src/components/translator/TranslatorTab.test.tsx

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ const createRouterNode = (
9797
describe(TranslatorTab.name, () => {
9898
it('renders', () => {
9999
const { baseElement, getByText } = render(<TranslatorTab {...translatorProps} />);
100-
getByText('Spanish Translations');
100+
getByText('Spanish');
101101
expect(baseElement).toMatchSnapshot();
102102
});
103103

@@ -109,7 +109,6 @@ describe(TranslatorTab.name, () => {
109109

110110
// we pulled out all the localizable bits
111111
getByText('Hello World!');
112-
getByText('Quick Replies');
113112

114113
getByText('0%');
115114
expect(baseElement).toMatchSnapshot();
@@ -144,9 +143,6 @@ describe(TranslatorTab.name, () => {
144143
// category list
145144
getByText('Red, Green, Blue, Other');
146145

147-
// rule list
148-
getByText('red, green, blue');
149-
150146
expect(baseElement).toMatchSnapshot();
151147
});
152148

@@ -161,8 +157,6 @@ describe(TranslatorTab.name, () => {
161157

162158
// category list
163159
getByText('Blue, Other');
164-
getByText('29%');
165-
166160
expect(baseElement).toMatchSnapshot();
167161
});
168162

@@ -175,7 +169,6 @@ describe(TranslatorTab.name, () => {
175169

176170
rerender(<TranslatorTab {...translatorProps} {...updates} />);
177171
expect(queryByText('Hello World!')).toBeNull();
178-
getByText('50%');
179172
expect(baseElement).toMatchSnapshot();
180173
});
181174
});

0 commit comments

Comments
 (0)