mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
chore: support more language (#5522)
* chore: support more language * chore: adjust ui
This commit is contained in:
parent
4708c0f779
commit
f1a4deb459
@ -57,14 +57,24 @@ class TranslateTypeOptionState with _$TranslateTypeOptionState {
|
||||
|
||||
String languageTypeToLanguage(TranslateLanguagePB langaugeType) {
|
||||
switch (langaugeType) {
|
||||
case TranslateLanguagePB.Chinese:
|
||||
return 'Chinese';
|
||||
case TranslateLanguagePB.SimplifiedChinese:
|
||||
return 'Simplified Chinese';
|
||||
case TranslateLanguagePB.TraditionalChinese:
|
||||
return 'Traditional Chinese';
|
||||
case TranslateLanguagePB.English:
|
||||
return 'English';
|
||||
case TranslateLanguagePB.French:
|
||||
return 'French';
|
||||
case TranslateLanguagePB.German:
|
||||
return 'German';
|
||||
case TranslateLanguagePB.Spanish:
|
||||
return 'Spanish';
|
||||
case TranslateLanguagePB.Hindi:
|
||||
return 'Hindi';
|
||||
case TranslateLanguagePB.Portuguese:
|
||||
return 'Portuguese';
|
||||
case TranslateLanguagePB.StandardArabic:
|
||||
return 'Standard Arabic';
|
||||
default:
|
||||
Log.error('Unknown language type: $langaugeType');
|
||||
return 'English';
|
||||
|
@ -32,24 +32,27 @@ class DesktopGridSummaryCellSkin extends IEditableSummaryCellSkin {
|
||||
minHeight: GridSize.headerHeight,
|
||||
),
|
||||
child: Stack(
|
||||
fit: StackFit.expand,
|
||||
children: [
|
||||
TextField(
|
||||
controller: textEditingController,
|
||||
enabled: false,
|
||||
focusNode: focusNode,
|
||||
onEditingComplete: () => focusNode.unfocus(),
|
||||
onSubmitted: (_) => focusNode.unfocus(),
|
||||
maxLines: null,
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
textInputAction: TextInputAction.done,
|
||||
decoration: InputDecoration(
|
||||
contentPadding: GridSize.cellContentInsets,
|
||||
border: InputBorder.none,
|
||||
focusedBorder: InputBorder.none,
|
||||
enabledBorder: InputBorder.none,
|
||||
errorBorder: InputBorder.none,
|
||||
disabledBorder: InputBorder.none,
|
||||
isDense: true,
|
||||
Center(
|
||||
child: TextField(
|
||||
controller: textEditingController,
|
||||
enabled: false,
|
||||
focusNode: focusNode,
|
||||
onEditingComplete: () => focusNode.unfocus(),
|
||||
onSubmitted: (_) => focusNode.unfocus(),
|
||||
maxLines: null,
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
textInputAction: TextInputAction.done,
|
||||
decoration: InputDecoration(
|
||||
contentPadding: GridSize.cellContentInsets,
|
||||
border: InputBorder.none,
|
||||
focusedBorder: InputBorder.none,
|
||||
enabledBorder: InputBorder.none,
|
||||
errorBorder: InputBorder.none,
|
||||
disabledBorder: InputBorder.none,
|
||||
isDense: true,
|
||||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
|
@ -32,24 +32,27 @@ class DesktopGridTranslateCellSkin extends IEditableTranslateCellSkin {
|
||||
minHeight: GridSize.headerHeight,
|
||||
),
|
||||
child: Stack(
|
||||
fit: StackFit.expand,
|
||||
children: [
|
||||
TextField(
|
||||
controller: textEditingController,
|
||||
enabled: false,
|
||||
focusNode: focusNode,
|
||||
onEditingComplete: () => focusNode.unfocus(),
|
||||
onSubmitted: (_) => focusNode.unfocus(),
|
||||
maxLines: null,
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
textInputAction: TextInputAction.done,
|
||||
decoration: InputDecoration(
|
||||
contentPadding: GridSize.cellContentInsets,
|
||||
border: InputBorder.none,
|
||||
focusedBorder: InputBorder.none,
|
||||
enabledBorder: InputBorder.none,
|
||||
errorBorder: InputBorder.none,
|
||||
disabledBorder: InputBorder.none,
|
||||
isDense: true,
|
||||
Center(
|
||||
child: TextField(
|
||||
controller: textEditingController,
|
||||
readOnly: true,
|
||||
focusNode: focusNode,
|
||||
onEditingComplete: () => focusNode.unfocus(),
|
||||
onSubmitted: (_) => focusNode.unfocus(),
|
||||
maxLines: null,
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
textInputAction: TextInputAction.done,
|
||||
decoration: InputDecoration(
|
||||
contentPadding: GridSize.cellContentInsets,
|
||||
border: InputBorder.none,
|
||||
focusedBorder: InputBorder.none,
|
||||
enabledBorder: InputBorder.none,
|
||||
errorBorder: InputBorder.none,
|
||||
disabledBorder: InputBorder.none,
|
||||
isDense: true,
|
||||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
|
@ -3,6 +3,7 @@ import 'package:appflowy/plugins/database/grid/presentation/layout/sizes.dart';
|
||||
import 'package:appflowy/plugins/database/widgets/cell/editable_cell_skeleton/summary.dart';
|
||||
import 'package:appflowy/plugins/database/widgets/row/cells/cell_container.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class DesktopRowDetailSummaryCellSkin extends IEditableSummaryCellSkin {
|
||||
@override
|
||||
@ -13,41 +14,53 @@ class DesktopRowDetailSummaryCellSkin extends IEditableSummaryCellSkin {
|
||||
FocusNode focusNode,
|
||||
TextEditingController textEditingController,
|
||||
) {
|
||||
return Column(
|
||||
children: [
|
||||
TextField(
|
||||
controller: textEditingController,
|
||||
focusNode: focusNode,
|
||||
onEditingComplete: () => focusNode.unfocus(),
|
||||
onSubmitted: (_) => focusNode.unfocus(),
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
textInputAction: TextInputAction.done,
|
||||
maxLines: null,
|
||||
minLines: 1,
|
||||
decoration: InputDecoration(
|
||||
contentPadding: GridSize.cellContentInsets,
|
||||
border: InputBorder.none,
|
||||
focusedBorder: InputBorder.none,
|
||||
enabledBorder: InputBorder.none,
|
||||
errorBorder: InputBorder.none,
|
||||
disabledBorder: InputBorder.none,
|
||||
isDense: true,
|
||||
),
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
const Spacer(),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: SummaryCellAccessory(
|
||||
viewId: bloc.cellController.viewId,
|
||||
fieldId: bloc.cellController.fieldId,
|
||||
rowId: bloc.cellController.rowId,
|
||||
),
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Stack(
|
||||
children: [
|
||||
TextField(
|
||||
controller: textEditingController,
|
||||
readOnly: true,
|
||||
focusNode: focusNode,
|
||||
onEditingComplete: () => focusNode.unfocus(),
|
||||
onSubmitted: (_) => focusNode.unfocus(),
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
textInputAction: TextInputAction.done,
|
||||
maxLines: null,
|
||||
minLines: 1,
|
||||
decoration: InputDecoration(
|
||||
contentPadding: GridSize.cellContentInsets,
|
||||
border: InputBorder.none,
|
||||
focusedBorder: InputBorder.none,
|
||||
enabledBorder: InputBorder.none,
|
||||
errorBorder: InputBorder.none,
|
||||
disabledBorder: InputBorder.none,
|
||||
isDense: true,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
ChangeNotifierProvider.value(
|
||||
value: cellContainerNotifier,
|
||||
child: Selector<CellContainerNotifier, bool>(
|
||||
selector: (_, notifier) => notifier.isHover,
|
||||
builder: (context, isHover, child) {
|
||||
return Visibility(
|
||||
visible: isHover,
|
||||
child: Row(
|
||||
children: [
|
||||
const Spacer(),
|
||||
SummaryCellAccessory(
|
||||
viewId: bloc.cellController.viewId,
|
||||
fieldId: bloc.cellController.fieldId,
|
||||
rowId: bloc.cellController.rowId,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ import 'package:appflowy/plugins/database/grid/presentation/layout/sizes.dart';
|
||||
import 'package:appflowy/plugins/database/widgets/cell/editable_cell_skeleton/translate.dart';
|
||||
import 'package:appflowy/plugins/database/widgets/row/cells/cell_container.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class DesktopRowDetailTranslateCellSkin extends IEditableTranslateCellSkin {
|
||||
@override
|
||||
@ -13,41 +14,53 @@ class DesktopRowDetailTranslateCellSkin extends IEditableTranslateCellSkin {
|
||||
FocusNode focusNode,
|
||||
TextEditingController textEditingController,
|
||||
) {
|
||||
return Column(
|
||||
children: [
|
||||
TextField(
|
||||
controller: textEditingController,
|
||||
focusNode: focusNode,
|
||||
onEditingComplete: () => focusNode.unfocus(),
|
||||
onSubmitted: (_) => focusNode.unfocus(),
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
textInputAction: TextInputAction.done,
|
||||
maxLines: null,
|
||||
minLines: 1,
|
||||
decoration: InputDecoration(
|
||||
contentPadding: GridSize.cellContentInsets,
|
||||
border: InputBorder.none,
|
||||
focusedBorder: InputBorder.none,
|
||||
enabledBorder: InputBorder.none,
|
||||
errorBorder: InputBorder.none,
|
||||
disabledBorder: InputBorder.none,
|
||||
isDense: true,
|
||||
),
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
const Spacer(),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: TranslateCellAccessory(
|
||||
viewId: bloc.cellController.viewId,
|
||||
fieldId: bloc.cellController.fieldId,
|
||||
rowId: bloc.cellController.rowId,
|
||||
),
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Stack(
|
||||
children: [
|
||||
TextField(
|
||||
controller: textEditingController,
|
||||
focusNode: focusNode,
|
||||
readOnly: true,
|
||||
onEditingComplete: () => focusNode.unfocus(),
|
||||
onSubmitted: (_) => focusNode.unfocus(),
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
textInputAction: TextInputAction.done,
|
||||
maxLines: null,
|
||||
minLines: 1,
|
||||
decoration: InputDecoration(
|
||||
contentPadding: GridSize.cellContentInsets,
|
||||
border: InputBorder.none,
|
||||
focusedBorder: InputBorder.none,
|
||||
enabledBorder: InputBorder.none,
|
||||
errorBorder: InputBorder.none,
|
||||
disabledBorder: InputBorder.none,
|
||||
isDense: true,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
ChangeNotifierProvider.value(
|
||||
value: cellContainerNotifier,
|
||||
child: Selector<CellContainerNotifier, bool>(
|
||||
selector: (_, notifier) => notifier.isHover,
|
||||
builder: (context, isHover, child) {
|
||||
return Visibility(
|
||||
visible: isHover,
|
||||
child: Row(
|
||||
children: [
|
||||
const Spacer(),
|
||||
TranslateCellAccessory(
|
||||
viewId: bloc.cellController.viewId,
|
||||
fieldId: bloc.cellController.fieldId,
|
||||
rowId: bloc.cellController.rowId,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ class MobileGridSummaryCellSkin extends IEditableSummaryCellSkin {
|
||||
children: [
|
||||
TextField(
|
||||
controller: textEditingController,
|
||||
enabled: false,
|
||||
readOnly: true,
|
||||
focusNode: focusNode,
|
||||
onEditingComplete: () => focusNode.unfocus(),
|
||||
onSubmitted: (_) => focusNode.unfocus(),
|
||||
|
@ -32,7 +32,7 @@ class MobileGridTranslateCellSkin extends IEditableTranslateCellSkin {
|
||||
children: [
|
||||
TextField(
|
||||
controller: textEditingController,
|
||||
enabled: false,
|
||||
readOnly: true,
|
||||
focusNode: focusNode,
|
||||
onEditingComplete: () => focusNode.unfocus(),
|
||||
onSubmitted: (_) => focusNode.unfocus(),
|
||||
|
@ -17,6 +17,7 @@ class MobileRowDetailSummaryCellSkin extends IEditableSummaryCellSkin {
|
||||
children: [
|
||||
TextField(
|
||||
controller: textEditingController,
|
||||
readOnly: true,
|
||||
focusNode: focusNode,
|
||||
onEditingComplete: () => focusNode.unfocus(),
|
||||
onSubmitted: (_) => focusNode.unfocus(),
|
||||
|
@ -16,6 +16,7 @@ class MobileRowDetailTranslateCellSkin extends IEditableTranslateCellSkin {
|
||||
return Column(
|
||||
children: [
|
||||
TextField(
|
||||
readOnly: true,
|
||||
controller: textEditingController,
|
||||
focusNode: focusNode,
|
||||
onEditingComplete: () => focusNode.unfocus(),
|
||||
|
@ -96,7 +96,7 @@ class SelectLanguageButton extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SizedBox(
|
||||
height: 40,
|
||||
height: 30,
|
||||
child: FlowyButton(text: FlowyText(language)),
|
||||
);
|
||||
}
|
||||
|
@ -126,8 +126,13 @@ impl FolderTest {
|
||||
let app = create_view(sdk, &self.workspace.id, &name, &desc, ViewLayout::Document).await;
|
||||
self.parent_view = app;
|
||||
},
|
||||
FolderScript::AssertParentView(app) => {
|
||||
assert_eq!(self.parent_view, app, "App not equal");
|
||||
FolderScript::AssertParentView(view) => {
|
||||
assert_eq!(self.parent_view.id, view.id, "view id not equal");
|
||||
assert_eq!(self.parent_view.name, view.name, "view name not equal");
|
||||
assert_eq!(
|
||||
self.parent_view.is_favorite, view.is_favorite,
|
||||
"view name not equal"
|
||||
);
|
||||
},
|
||||
FolderScript::ReloadParentView(parent_view_id) => {
|
||||
let parent_view = read_view(sdk, &parent_view_id).await;
|
||||
|
@ -30,20 +30,30 @@ impl From<TranslateTypeOptionPB> for TranslateTypeOption {
|
||||
#[derive(Clone, Debug, Copy, ProtoBuf_Enum, Default)]
|
||||
#[repr(i64)]
|
||||
pub enum TranslateLanguagePB {
|
||||
Chinese = 0,
|
||||
TraditionalChinese = 0,
|
||||
#[default]
|
||||
English = 1,
|
||||
French = 2,
|
||||
German = 3,
|
||||
Hindi = 4,
|
||||
Spanish = 5,
|
||||
Portuguese = 6,
|
||||
StandardArabic = 7,
|
||||
SimplifiedChinese = 8,
|
||||
}
|
||||
|
||||
impl From<i64> for TranslateLanguagePB {
|
||||
fn from(data: i64) -> Self {
|
||||
match data {
|
||||
0 => TranslateLanguagePB::Chinese,
|
||||
0 => TranslateLanguagePB::TraditionalChinese,
|
||||
1 => TranslateLanguagePB::English,
|
||||
2 => TranslateLanguagePB::French,
|
||||
3 => TranslateLanguagePB::German,
|
||||
4 => TranslateLanguagePB::Hindi,
|
||||
5 => TranslateLanguagePB::Spanish,
|
||||
6 => TranslateLanguagePB::Portuguese,
|
||||
7 => TranslateLanguagePB::StandardArabic,
|
||||
8 => TranslateLanguagePB::SimplifiedChinese,
|
||||
_ => TranslateLanguagePB::English,
|
||||
}
|
||||
}
|
||||
|
@ -428,8 +428,6 @@ impl DatabaseManager {
|
||||
field_id: String,
|
||||
) -> FlowyResult<()> {
|
||||
let database = self.get_database_with_view_id(&view_id).await?;
|
||||
|
||||
//
|
||||
let mut summary_row_content = SummaryRowContent::new();
|
||||
if let Some(row) = database.get_row(&view_id, &row_id) {
|
||||
let fields = database.get_fields(&view_id, None);
|
||||
@ -437,6 +435,10 @@ impl DatabaseManager {
|
||||
// When summarizing a row, skip the content in the "AI summary" cell; it does not need to
|
||||
// be summarized.
|
||||
if field.id != field_id {
|
||||
// Don't summarize the summary field.
|
||||
if field.field_type == FieldType::Summary as i64 {
|
||||
continue;
|
||||
}
|
||||
if let Some(cell) = row.cells.get(&field.id) {
|
||||
summary_row_content.insert(field.name.clone(), stringify_cell(cell, &field));
|
||||
}
|
||||
@ -480,6 +482,11 @@ impl DatabaseManager {
|
||||
// When translate a row, skip the content in the "AI Translate" cell; it does not need to
|
||||
// be translated.
|
||||
if field.id != field_id {
|
||||
// Don't translate the translate field.
|
||||
if field.field_type == FieldType::Translate as i64 {
|
||||
continue;
|
||||
}
|
||||
|
||||
if let Some(cell) = row.cells.get(&field.id) {
|
||||
translate_row_content.push(TranslateItem {
|
||||
title: field.name.clone(),
|
||||
|
@ -23,10 +23,15 @@ pub struct TranslateTypeOption {
|
||||
impl TranslateTypeOption {
|
||||
pub fn language_from_type(language_type: i64) -> &'static str {
|
||||
match language_type {
|
||||
0 => "Chinese",
|
||||
0 => "Traditional Chinese",
|
||||
1 => "English",
|
||||
2 => "French",
|
||||
3 => "German",
|
||||
4 => "Hindi",
|
||||
5 => "Spanish",
|
||||
6 => "Portuguese",
|
||||
7 => "Standard Arabic",
|
||||
8 => "Simplified Chinese",
|
||||
_ => "English",
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ use crate::database::mock_data::{COMPLETED, FACEBOOK, GOOGLE, PAUSED, PLANNED, T
|
||||
use event_integration_test::database_event::TestRowBuilder;
|
||||
use flowy_database2::entities::FieldType;
|
||||
use flowy_database2::services::field::summary_type_option::summary::SummarizationTypeOption;
|
||||
use flowy_database2::services::field::translate_type_option::translate::TranslateTypeOption;
|
||||
use flowy_database2::services::field::{
|
||||
ChecklistTypeOption, DateFormat, DateTypeOption, FieldBuilder, MultiSelectTypeOption,
|
||||
NumberFormat, NumberTypeOption, RelationTypeOption, SelectOption, SelectOptionColor,
|
||||
@ -132,7 +133,16 @@ pub fn make_test_grid() -> DatabaseData {
|
||||
.build();
|
||||
fields.push(relation_field);
|
||||
},
|
||||
FieldType::Translate => {},
|
||||
FieldType::Translate => {
|
||||
let type_option = TranslateTypeOption {
|
||||
auto_fill: false,
|
||||
language_type: 0,
|
||||
};
|
||||
let translate_field = FieldBuilder::new(field_type, type_option)
|
||||
.name("AI translate")
|
||||
.build();
|
||||
fields.push(translate_field);
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user