diff --git a/assets/images/toolbar/text_direction_right.svg b/assets/images/toolbar/text_direction_ltr.svg similarity index 100% rename from assets/images/toolbar/text_direction_right.svg rename to assets/images/toolbar/text_direction_ltr.svg diff --git a/assets/images/toolbar/text_direction_left.svg b/assets/images/toolbar/text_direction_rtl.svg similarity index 100% rename from assets/images/toolbar/text_direction_left.svg rename to assets/images/toolbar/text_direction_rtl.svg diff --git a/documentation/translation.md b/documentation/translation.md index 78ad41ce..d9929eed 100644 --- a/documentation/translation.md +++ b/documentation/translation.md @@ -13,4 +13,47 @@ Translation files are located in: `lib/l10n/` 1. Install the Visual Studio Code plugin: [Flutter intl](https://marketplace.visualstudio.com/items?itemName=localizely.flutter-intl) 2. Copy the `intl_en.arb` as a base translation and rename the new file to `intl_.arb` 3. Modify the new translation file. -4. Save the file and the translation will be generated automatically. \ No newline at end of file +4. Save the file and the translation will be generated automatically. + +## Modify the locale of the editor + +If you want to try the changes you made, you can modify the locale of the editor by changing the `supportedLocales` variable in [example/lib/main.dart](../example/lib/main.dart) to the locale you want to test. + +```dart +// example/lib/main.dart +// Change this: +supportedLocales: AppFlowyEditorLocalizations.delegate.supportedLocales, +// to the locale you want to test, for example fr_FR: +supportedLocales: const [Locale('fr', 'FR')], +``` + +Or you can do it interactively by adding a Floating Action Button to the page. Edit [example/lib/home_page.dart](../example/lib/home_page.dart): + +> You need to rebuild to see the changes of the translated strings. + +```dart +// example/lib/home_page.dart +class _HomePageState extends State { + // other code... + + @override + Widget build(BuildContext context) { + return Scaffold( + // other code... + floatingActionButton: FloatingActionButton( + onPressed: toggleLocale, + child: const Icon(Icons.language), + ), + ); + } + + void toggleLocale() { + final locale = Intl.getCurrentLocale(); + if (locale == 'en_US') { + // Change to the locale you want to test + AppFlowyEditorLocalizations.load(const Locale('pt', 'BR')); + } else { + AppFlowyEditorLocalizations.load(const Locale('en', 'US')); + } + } +``` diff --git a/example/lib/main.dart b/example/lib/main.dart index 782433b1..034a241c 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -19,7 +19,7 @@ class MyApp extends StatelessWidget { GlobalWidgetsLocalizations.delegate, AppFlowyEditorLocalizations.delegate, ], - supportedLocales: const [Locale('en', 'US')], + supportedLocales: AppFlowyEditorLocalizations.delegate.supportedLocales, debugShowCheckedModeBanner: false, home: const HomePage(), theme: ThemeData.light(useMaterial3: true), diff --git a/lib/l10n/intl_en.arb b/lib/l10n/intl_en.arb index 6d546759..0c3b38af 100644 --- a/lib/l10n/intl_en.arb +++ b/lib/l10n/intl_en.arb @@ -1,79 +1,42 @@ { "@@locale": "en", "bold": "Bold", - "@bold": {}, "bulletedList": "Bulleted List", - "@bulletedList": {}, "checkbox": "Checkbox", - "@checkbox": {}, "embedCode": "Embed Code", - "@embedCode": {}, "heading1": "H1", - "@heading1": {}, "heading2": "H2", - "@heading2": {}, "heading3": "H3", - "@heading3": {}, "highlight": "Highlight", - "@highlight": {}, "color": "Color", - "@color": {}, "image": "Image", - "@image": {}, "italic": "Italic", - "@italic": {}, "link": "Link", - "@link": {}, "numberedList": "Numbered List", - "@numberedList": {}, "quote": "Quote", - "@quote": {}, "strikethrough": "Strikethrough", - "@strikethrough": {}, "text": "Text", - "@text": {}, "underline": "Underline", - "@underline": {}, "fontColorDefault": "Default", - "@fontColorDefault": {}, "fontColorGray": "Gray", - "@fontColorGray": {}, "fontColorBrown": "Brown", - "@fontColorBrown": {}, "fontColorOrange": "Orange", - "@fontColorOrange": {}, "fontColorYellow": "Yellow", - "@fontColorYellow": {}, "fontColorGreen": "Green", - "@fontColorGreen": {}, "fontColorBlue": "Blue", - "@fontColorBlue": {}, "fontColorPurple": "Purple", - "@fontColorPurple": {}, "fontColorPink": "Pink", - "@fontColorPink": {}, "fontColorRed": "Red", - "@fontColorRed": {}, "backgroundColorDefault": "Default background", - "@backgroundColorDefault": {}, "backgroundColorGray": "Gray background", - "@backgroundColorGray": {}, "backgroundColorBrown": "Brown background", - "@backgroundColorBrown": {}, "backgroundColorOrange": "Orange background", - "@backgroundColorOrange": {}, "backgroundColorYellow": "Yellow background", - "@backgroundColorYellow": {}, "backgroundColorGreen": "Green background", - "@backgroundColorGreen": {}, "backgroundColorBlue": "Blue background", - "@backgroundColorBlue": {}, "backgroundColorPurple": "Purple background", - "@backgroundColorPurple": {}, "backgroundColorPink": "Pink background", - "@backgroundColorPink": {}, "backgroundColorRed": "Red background", - "@backgroundColorRed": {}, "done": "Done", "cancel": "Cancel", "tint1": "Tint 1", @@ -94,6 +57,8 @@ "lightLightTint7": "Green", "lightLightTint8": "Aqua", "lightLightTint9": "Blue", + "listItemPlaceholder": "List item", + "toDoPlaceholder": "To-do", "urlHint": "URL", "mobileHeading1": "Heading 1", "mobileHeading2": "Heading 2", @@ -108,7 +73,7 @@ "linkText": "Text", "linkTextHint": "Please enter text", "linkAddressHint": "Please enter URL", - "highlightColor": "Highlight color", + "highlightColor": "Highlight Color", "clearHighlightColor": "Clear highlight color", "customColor": "Custom color", "hexValue": "Hex value", @@ -131,8 +96,8 @@ "regexError": "Regex Error", "noFindResult": "No result", "emptySearchBoxHint": "Enter a pattern", - "uploadImage": "Upload Image", - "urlImage": "URL Image", + "uploadImage": "Upload", + "urlImage": "URL", "incorrectLink": "Incorrect Link", "upload": "Upload", "chooseImage": "Choose an image", @@ -150,5 +115,16 @@ "rowDuplicate": "Duplicate", "colClear": "Clear Content", "rowClear": "Clear Content", - "slashPlaceHolder": "Enter a / to insert a block, or start typing" + "slashPlaceHolder": "Enter a / to insert a block, or start typing", + "textAlignLeft": "Align Left", + "textAlignCenter": "Align Center", + "textAlignRight": "Align Right", + "cmdDontAddNewLineInTableCell": "Don't add new line in table cell", + "cmdMoveToLeftCellIfItsAtStartOfCurrentCell": "Move to left cell if its at start of current cell", + "cmdMoveToRightCellIfItsAtTheEndOfCurrentCell": "Move to right cell if its at the end of current cell", + "cmdMoveToUpCellAtSameOffset": "Move to up cell at same offset", + "cmdMoveToDownCellAtSameOffset": "Move to down cell at same offset", + "cmdNavigateAroundTheCellsAtSameOffset": "Navigate around the cells at same offset", + "cmdNavigateAroundTheCellsAtSameOffsetInReverse": "Navigate around the cells at same offset in reverse", + "cmdStopAtTheBeginningOfTheCell": "Stop at the beginning of the cell" } diff --git a/lib/l10n/intl_pt_BR.arb b/lib/l10n/intl_pt_BR.arb index 8f9186b7..84f96aa7 100644 --- a/lib/l10n/intl_pt_BR.arb +++ b/lib/l10n/intl_pt_BR.arb @@ -1,35 +1,130 @@ { "@@locale": "pt-BR", + "addYourLink": "Adicionar seu link", + "auto": "Automático", + "backgroundColor": "Cor de fundo", + "backgroundColorBlue": "Fundo azul", + "backgroundColorBrown": "Fundo marrom", + "backgroundColorDefault": "Fundo padrão", + "backgroundColorGray": "Fundo cinza", + "backgroundColorGreen": "Fundo verde", + "backgroundColorOrange": "Fundo laranja", + "backgroundColorPink": "Fundo rosa", + "backgroundColorPurple": "Fundo roxo", + "backgroundColorRed": "Fundo vermelho\n", + "backgroundColorYellow": "Fundo amarelo", "bold": "Negrito", - "@bold": {}, "bulletedList": "Lista de marcadores", - "@bulletedList": {}, + "cancel": "Cancelar", + "caseSensitive": "Diferenciar maiúsculas", "checkbox": "Caixa de seleção", - "@checkbox": {}, + "chooseImage": "Selecionar imagem", + "clearHighlightColor": "Limpar cor de destaque", + "closeFind": "Fechar", + "cmdDontAddNewLineInTableCell": "Não adicionar nova linha na célula", + "cmdMoveToDownCellAtSameOffset": "Mover para a célula abaixo na mesma posição", + "cmdMoveToLeftCellIfItsAtStartOfCurrentCell": "Mover para a célula à esquerda se estiver no início da célula atual", + "cmdMoveToRightCellIfItsAtTheEndOfCurrentCell": "Mover para a célula à direita se estiver no final da célula atual", + "cmdMoveToUpCellAtSameOffset": "Mover para a célula acima na mesma posição", + "cmdNavigateAroundTheCellsAtSameOffset": "Navegar pelas células na mesma posição", + "cmdNavigateAroundTheCellsAtSameOffsetInReverse": "Navegar pelas células na mesma posição (reverso)", + "cmdStopAtTheBeginningOfTheCell": "Parar no início da célula", + "colAddAfter": "Inserir à direita", + "colAddBefore": "Inserir à esquerda", + "colClear": "Limpar coluna", + "colDuplicate": "Duplicar coluna", + "color": "Cor", + "colRemove": "Deletar coluna", + "copy": "Copiar", + "copyLink": "Copiar link", + "customColor": "Cor personalizada", + "cut": "Cortar", + "divider": "Separador", + "done": "Concluir", + "editLink": "Editar link", "embedCode": "Código incorporado", - "@embedCode": {}, - "heading1": "H1", - "@heading1": {}, - "heading2": "H2", - "@heading2": {}, - "heading3": "H3", - "@heading3": {}, + "emptySearchBoxHint": "Localizar...", + "find": "Procurar", + "fontColorBlue": "Azul", + "fontColorBrown": "Marrom", + "fontColorDefault": "Padrão", + "fontColorGray": "Cinza", + "fontColorGreen": "Verde", + "fontColorOrange": "Laranja", + "fontColorPink": "Rosa", + "fontColorPurple": "Roxo", + "fontColorRed": "Vermelho", + "fontColorYellow": "Amarelo", + "heading1": "Cabeçalho 1", + "heading2": "Cabeçalho 2", + "heading3": "Cabeçalho 3", + "hexValue": "HEX", "highlight": "Destacar", - "@highlight": {}, + "highlightColor": "Cor de destaque", "image": "Imagem", - "@image": {}, + "imageLoadFailed": "Não foi possível carregar a imagem", + "incorrectLink": "Link incorreto", "italic": "Itálico", - "@italic": {}, + "lightLightTint1": "Roxo", + "lightLightTint2": "Rosa", + "lightLightTint3": "Rosa claro", + "lightLightTint4": "Laranja", + "lightLightTint5": "Amarelo", + "lightLightTint6": "Lima", + "lightLightTint7": "Verde", + "lightLightTint8": "Aqua", + "lightLightTint9": "Azul", "link": "Link", - "@link": {}, + "linkAddressHint": "Insira a URL", + "linkText": "Texto", + "linkTextHint": "Insira o rótulo", + "listItemPlaceholder": "Item de lista", + "toDoPlaceholder": "Tarefa a fazer", + "loading": "Carregando", + "ltr": "Esquerda para Direita", + "mobileHeading1": "Cabeçalho 1", + "mobileHeading2": "Cabeçalho 2", + "mobileHeading3": "Cabeçalho 3", + "nextMatch": "Próximo", + "noFindResult": "Nenhum resultado encontrado", "numberedList": "Lista numerada", - "@numberedList": {}, - "quote": "Citar", - "@quote": {}, + "opacity": "Opacidade", + "openLink": "Abrir link", + "paste": "Colar", + "previousMatch": "Anterior", + "quote": "Citação", + "regex": "Regex", + "regexError": "Erro de Regex", + "removeLink": "Remover link", + "replace": "Substituir", + "replaceAll": "Substituir tudo", + "resetToDefaultColor": "Redefinir para cor padrão", + "rowAddAfter": "Inserir abaixo", + "rowAddBefore": "Inserir acima", + "rowClear": "Limpar linha", + "rowDuplicate": "Duplicar linha", + "rowRemove": "Deletar linha", + "rtl": "Direita para Esquerda", + "slashPlaceHolder": "Insira / para adicionar um bloco ou comece a escrever", "strikethrough": "Rasurar", - "@strikethrough": {}, + "table": "Tabela", "text": "Texto", - "@text": {}, + "textAlignCenter": "Alinhar ao centro", + "textAlignLeft": "Alinhar à esquerda", + "textAlignRight": "Alinhar à direita", + "textColor": "Cor do texto", + "tint1": "Matiz 1", + "tint2": "Matiz 2", + "tint3": "Matiz 3", + "tint4": "Matiz 4", + "tint5": "Matiz 5", + "tint6": "Matiz 6", + "tint7": "Matiz 7", + "tint8": "Matiz 8", + "tint9": "Matiz 9", "underline": "Sublinhar", - "@underline": {} -} \ No newline at end of file + "upload": "Enviar", + "uploadImage": "Enviar", + "urlHint": "URL", + "urlImage": "URL" +} diff --git a/lib/l10n/intl_pt_PT.arb b/lib/l10n/intl_pt_PT.arb index 9b7386fd..b0fd049f 100644 --- a/lib/l10n/intl_pt_PT.arb +++ b/lib/l10n/intl_pt_PT.arb @@ -8,11 +8,11 @@ "@checkbox": {}, "embedCode": "Código embutido", "@embedCode": {}, - "heading1": "Cabeçallho 1", + "heading1": "Cabeçalho 1", "@heading1": {}, - "heading2": "Cabeçallho 2", + "heading2": "Cabeçalho 2", "@heading2": {}, - "heading3": "Cabeçallho 3", + "heading3": "Cabeçalho 3", "@heading3": {}, "highlight": "realçar", "@highlight": {}, @@ -31,5 +31,21 @@ "text": "texto", "@text": {}, "underline": "sublinhado", - "@underline": {} -} \ No newline at end of file + "@underline": {}, + "ltr": "Esquerda para Direita", + "rtl": "Direita para Esquerda", + "auto": "Automático", + "highlightColor": "Cor de destaque", + "textColor": "Cor do texto", + "textAlignLeft": "Alinhar à esquerda", + "textAlignCenter": "Alinhar ao centro", + "textAlignRight": "Alinhar à direita", + "cmdDontAddNewLineInTableCell": "Não adicionar nova linha na célula", + "cmdMoveToLeftCellIfItsAtStartOfCurrentCell": "Mover para a célula à esquerda se estiver no início da célula atual", + "cmdMoveToRightCellIfItsAtTheEndOfCurrentCell": "Mover para a célula à direita se estiver no final da célula atual", + "cmdMoveToUpCellAtSameOffset": "Mover para a célula acima na mesma posição", + "cmdMoveToDownCellAtSameOffset": "Mover para a célula abaixo na mesma posição", + "cmdNavigateAroundTheCellsAtSameOffset": "Navegar pelas células na mesma posição", + "cmdNavigateAroundTheCellsAtSameOffsetInReverse": "Navegar pelas células na mesma posição (reverso)", + "cmdStopAtTheBeginningOfTheCell": "Parar no início da célula" +} diff --git a/lib/src/editor/block_component/divider_block_component/divider_menu_item.dart b/lib/src/editor/block_component/divider_block_component/divider_menu_item.dart index dc66ceb9..3a9b9594 100644 --- a/lib/src/editor/block_component/divider_block_component/divider_menu_item.dart +++ b/lib/src/editor/block_component/divider_block_component/divider_menu_item.dart @@ -2,7 +2,7 @@ import 'package:appflowy_editor/appflowy_editor.dart'; import 'package:flutter/material.dart'; SelectionMenuItem dividerMenuItem = SelectionMenuItem( - name: AppFlowyEditorL10n.current.divider, + getName: () => AppFlowyEditorL10n.current.divider, icon: (editorState, isSelected, style) => SelectionMenuIconWidget( icon: Icons.horizontal_rule, isSelected: isSelected, diff --git a/lib/src/editor/block_component/standard_block_components.dart b/lib/src/editor/block_component/standard_block_components.dart index 495a38df..3d9d0dc8 100644 --- a/lib/src/editor/block_component/standard_block_components.dart +++ b/lib/src/editor/block_component/standard_block_components.dart @@ -15,7 +15,7 @@ final Map standardBlockComponentBuilderMap = { ), TodoListBlockKeys.type: TodoListBlockComponentBuilder( configuration: standardBlockComponentConfiguration.copyWith( - placeholderText: (_) => 'To-do', + placeholderText: (_) => AppFlowyEditorL10n.current.toDoPlaceholder, ), toggleChildrenTriggers: [ LogicalKeyboardKey.shift, @@ -25,17 +25,17 @@ final Map standardBlockComponentBuilderMap = { ), BulletedListBlockKeys.type: BulletedListBlockComponentBuilder( configuration: standardBlockComponentConfiguration.copyWith( - placeholderText: (_) => 'List', + placeholderText: (_) => AppFlowyEditorL10n.current.listItemPlaceholder, ), ), NumberedListBlockKeys.type: NumberedListBlockComponentBuilder( configuration: standardBlockComponentConfiguration.copyWith( - placeholderText: (_) => 'List', + placeholderText: (_) => AppFlowyEditorL10n.current.listItemPlaceholder, ), ), QuoteBlockKeys.type: QuoteBlockComponentBuilder( configuration: standardBlockComponentConfiguration.copyWith( - placeholderText: (_) => 'Quote', + placeholderText: (_) => AppFlowyEditorL10n.current.quote, ), ), HeadingBlockKeys.type: HeadingBlockComponentBuilder( diff --git a/lib/src/editor/block_component/table_block_component/table_action_menu.dart b/lib/src/editor/block_component/table_block_component/table_action_menu.dart index 0fd4eb1a..7570e35b 100644 --- a/lib/src/editor/block_component/table_block_component/table_action_menu.dart +++ b/lib/src/editor/block_component/table_block_component/table_action_menu.dart @@ -38,17 +38,6 @@ void showActionMenu( width: 200, height: 230, children: [ - _menuItem( - context, - dir == TableDirection.col - ? AppFlowyEditorL10n.current.colAddAfter - : AppFlowyEditorL10n.current.rowAddAfter, - dir == TableDirection.col - ? Icons.last_page - : Icons.vertical_align_bottom, () { - TableActions.add(node, position + 1, editorState, dir); - dismissOverlay(); - }), _menuItem( context, dir == TableDirection.col @@ -60,6 +49,17 @@ void showActionMenu( TableActions.add(node, position, editorState, dir); dismissOverlay(); }), + _menuItem( + context, + dir == TableDirection.col + ? AppFlowyEditorL10n.current.colAddAfter + : AppFlowyEditorL10n.current.rowAddAfter, + dir == TableDirection.col + ? Icons.last_page + : Icons.vertical_align_bottom, () { + TableActions.add(node, position + 1, editorState, dir); + dismissOverlay(); + }), _menuItem( context, dir == TableDirection.col diff --git a/lib/src/editor/block_component/table_block_component/table_block_component.dart b/lib/src/editor/block_component/table_block_component/table_block_component.dart index a703252e..b90ebb3a 100644 --- a/lib/src/editor/block_component/table_block_component/table_block_component.dart +++ b/lib/src/editor/block_component/table_block_component/table_block_component.dart @@ -251,7 +251,7 @@ class _TableBlockComponentWidgetState extends State } SelectionMenuItem tableMenuItem = SelectionMenuItem( - name: AppFlowyEditorL10n.current.table, + getName: () => AppFlowyEditorL10n.current.table, icon: (editorState, isSelected, style) => SelectionMenuIconWidget( icon: Icons.table_view, isSelected: isSelected, diff --git a/lib/src/editor/block_component/table_block_component/table_commands.dart b/lib/src/editor/block_component/table_block_component/table_commands.dart index 02d8e183..d9bcea73 100644 --- a/lib/src/editor/block_component/table_block_component/table_commands.dart +++ b/lib/src/editor/block_component/table_block_component/table_commands.dart @@ -15,48 +15,62 @@ final List tableCommands = [ final CommandShortcutEvent _enterInTableCell = CommandShortcutEvent( key: 'Don\'t add new line in table cell', + getDescription: () => AppFlowyEditorL10n.current.cmdDontAddNewLineInTableCell, command: 'enter', handler: _enterInTableCellHandler, ); final CommandShortcutEvent _leftInTableCell = CommandShortcutEvent( key: 'Move to left cell if its at start of current cell', + getDescription: () => + AppFlowyEditorL10n.current.cmdMoveToLeftCellIfItsAtStartOfCurrentCell, command: 'arrow left', handler: _leftInTableCellHandler, ); final CommandShortcutEvent _rightInTableCell = CommandShortcutEvent( key: 'Move to right cell if its at the end of current cell', + getDescription: () => + AppFlowyEditorL10n.current.cmdMoveToRightCellIfItsAtTheEndOfCurrentCell, command: 'arrow right', handler: _rightInTableCellHandler, ); final CommandShortcutEvent _upInTableCell = CommandShortcutEvent( key: 'Move to up cell at same offset', + getDescription: () => AppFlowyEditorL10n.current.cmdMoveToUpCellAtSameOffset, command: 'arrow up', handler: _upInTableCellHandler, ); final CommandShortcutEvent _downInTableCell = CommandShortcutEvent( key: 'Move to down cell at same offset', + getDescription: () => + AppFlowyEditorL10n.current.cmdMoveToDownCellAtSameOffset, command: 'arrow down', handler: _downInTableCellHandler, ); final CommandShortcutEvent _tabInTableCell = CommandShortcutEvent( key: 'Navigate around the cells at same offset', + getDescription: () => + AppFlowyEditorL10n.current.cmdNavigateAroundTheCellsAtSameOffset, command: 'tab', handler: _tabInTableCellHandler, ); final CommandShortcutEvent _shiftTabInTableCell = CommandShortcutEvent( key: 'Navigate around the cells at same offset in reverse', + getDescription: () => + AppFlowyEditorL10n.current.cmdNavigateAroundTheCellsAtSameOffsetInReverse, command: 'shift+tab', handler: _shiftTabInTableCellHandler, ); final CommandShortcutEvent _backSpaceInTableCell = CommandShortcutEvent( key: 'Stop at the beginning of the cell', + getDescription: () => + AppFlowyEditorL10n.current.cmdStopAtTheBeginningOfTheCell, command: 'backspace', handler: _backspaceInTableCellHandler, ); diff --git a/lib/src/editor/editor_component/service/shortcuts/command_shortcut_event.dart b/lib/src/editor/editor_component/service/shortcuts/command_shortcut_event.dart index 0e378a96..c13d7549 100644 --- a/lib/src/editor/editor_component/service/shortcuts/command_shortcut_event.dart +++ b/lib/src/editor/editor_component/service/shortcuts/command_shortcut_event.dart @@ -11,10 +11,11 @@ class CommandShortcutEvent { required this.key, required this.command, required this.handler, + getDescription, String? windowsCommand, String? macOSCommand, String? linuxCommand, - }) { + }) : _getDescription = getDescription { updateCommand( command: command, windowsCommand: windowsCommand, @@ -46,11 +47,16 @@ class CommandShortcutEvent { /// String command; + /// Callback to return the localized description of the command. + final String Function()? _getDescription; + final CommandShortcutEventHandler handler; List get keybindings => _keybindings; List _keybindings = []; + String get description => _getDescription != null ? _getDescription!() : key; + void updateCommand({ String? command, String? windowsCommand, diff --git a/lib/src/editor/selection_menu/selection_menu_service.dart b/lib/src/editor/selection_menu/selection_menu_service.dart index a486915d..58193d35 100644 --- a/lib/src/editor/selection_menu/selection_menu_service.dart +++ b/lib/src/editor/selection_menu/selection_menu_service.dart @@ -238,7 +238,7 @@ class SelectionMenu extends SelectionMenuService { final List standardSelectionMenuItems = [ SelectionMenuItem( - name: AppFlowyEditorL10n.current.text, + getName: () => AppFlowyEditorL10n.current.text, icon: (editorState, isSelected, style) => SelectionMenuIconWidget( name: 'text', isSelected: isSelected, @@ -250,7 +250,7 @@ final List standardSelectionMenuItems = [ }, ), SelectionMenuItem( - name: AppFlowyEditorL10n.current.heading1, + getName: () => AppFlowyEditorL10n.current.heading1, icon: (editorState, isSelected, style) => SelectionMenuIconWidget( name: 'h1', isSelected: isSelected, @@ -262,7 +262,7 @@ final List standardSelectionMenuItems = [ }, ), SelectionMenuItem( - name: AppFlowyEditorL10n.current.heading2, + getName: () => AppFlowyEditorL10n.current.heading2, icon: (editorState, isSelected, style) => SelectionMenuIconWidget( name: 'h2', isSelected: isSelected, @@ -274,7 +274,7 @@ final List standardSelectionMenuItems = [ }, ), SelectionMenuItem( - name: AppFlowyEditorL10n.current.heading3, + getName: () => AppFlowyEditorL10n.current.heading3, icon: (editorState, isSelected, style) => SelectionMenuIconWidget( name: 'h3', isSelected: isSelected, @@ -286,7 +286,7 @@ final List standardSelectionMenuItems = [ }, ), SelectionMenuItem( - name: AppFlowyEditorL10n.current.image, + getName: () => AppFlowyEditorL10n.current.image, icon: (editorState, isSelected, style) => SelectionMenuIconWidget( name: 'image', isSelected: isSelected, @@ -299,7 +299,7 @@ final List standardSelectionMenuItems = [ }, ), SelectionMenuItem( - name: AppFlowyEditorL10n.current.bulletedList, + getName: () => AppFlowyEditorL10n.current.bulletedList, icon: (editorState, isSelected, style) => SelectionMenuIconWidget( name: 'bulleted_list', isSelected: isSelected, @@ -311,7 +311,7 @@ final List standardSelectionMenuItems = [ }, ), SelectionMenuItem( - name: AppFlowyEditorL10n.current.numberedList, + getName: () => AppFlowyEditorL10n.current.numberedList, icon: (editorState, isSelected, style) => SelectionMenuIconWidget( name: 'number', isSelected: isSelected, @@ -323,7 +323,7 @@ final List standardSelectionMenuItems = [ }, ), SelectionMenuItem( - name: AppFlowyEditorL10n.current.checkbox, + getName: () => AppFlowyEditorL10n.current.checkbox, icon: (editorState, isSelected, style) => SelectionMenuIconWidget( name: 'checkbox', isSelected: isSelected, @@ -335,7 +335,7 @@ final List standardSelectionMenuItems = [ }, ), SelectionMenuItem( - name: AppFlowyEditorL10n.current.quote, + getName: () => AppFlowyEditorL10n.current.quote, icon: (editorState, isSelected, style) => SelectionMenuIconWidget( name: 'quote', isSelected: isSelected, diff --git a/lib/src/editor/selection_menu/selection_menu_widget.dart b/lib/src/editor/selection_menu/selection_menu_widget.dart index 0439ecb4..e0a7476d 100644 --- a/lib/src/editor/selection_menu/selection_menu_widget.dart +++ b/lib/src/editor/selection_menu/selection_menu_widget.dart @@ -13,11 +13,11 @@ typedef SelectionMenuItemHandler = void Function( /// Selection Menu Item class SelectionMenuItem { SelectionMenuItem({ - required this.name, + required String Function() getName, required this.icon, required this.keywords, required SelectionMenuItemHandler handler, - }) { + }) : _getName = getName { this.handler = (editorState, menuService, context) { if (deleteSlash) { _deleteSlash(editorState); @@ -29,13 +29,15 @@ class SelectionMenuItem { }; } - final String name; + final String Function() _getName; final Widget Function( EditorState editorState, bool onSelected, SelectionMenuStyle style, ) icon; + String get name => _getName(); + /// Customizes keywords for item. /// /// The keywords are used to quickly retrieve items. @@ -97,7 +99,7 @@ class SelectionMenuItem { )? updateSelection, }) { return SelectionMenuItem( - name: name, + getName: () => name, icon: (editorState, onSelected, style) => Icon( iconData, color: onSelected diff --git a/lib/src/editor/toolbar/desktop/items/alignment_toolbar_items.dart b/lib/src/editor/toolbar/desktop/items/alignment_toolbar_items.dart index 13b02af8..1b32cb1a 100644 --- a/lib/src/editor/toolbar/desktop/items/alignment_toolbar_items.dart +++ b/lib/src/editor/toolbar/desktop/items/alignment_toolbar_items.dart @@ -1,22 +1,20 @@ import 'package:appflowy_editor/appflowy_editor.dart'; +import 'package:appflowy_editor/src/editor/toolbar/desktop/items/utils/tooltip_util.dart'; final List alignmentItems = [ _AlignmentToolbarItem( id: 'align_left', name: 'left', - tooltip: 'left', align: 'left', ), _AlignmentToolbarItem( id: 'align_center', name: 'center', - tooltip: 'center', align: 'center', ), _AlignmentToolbarItem( id: 'align_right', name: 'right', - tooltip: 'right', align: 'right', ), ]; @@ -25,7 +23,6 @@ class _AlignmentToolbarItem extends ToolbarItem { _AlignmentToolbarItem({ required String id, required String name, - required String tooltip, required String align, }) : super( id: 'editor.$id', @@ -43,7 +40,7 @@ class _AlignmentToolbarItem extends ToolbarItem { isHighlight: isHighlight, highlightColor: highlightColor, iconColor: iconColor, - tooltip: tooltip, + tooltip: getTooltipText(id), onPressed: () => editorState.updateNode( selection, (node) => node.copyWith( diff --git a/lib/src/editor/toolbar/desktop/items/format_toolbar_items.dart b/lib/src/editor/toolbar/desktop/items/format_toolbar_items.dart index 6115973d..528be933 100644 --- a/lib/src/editor/toolbar/desktop/items/format_toolbar_items.dart +++ b/lib/src/editor/toolbar/desktop/items/format_toolbar_items.dart @@ -5,32 +5,22 @@ final List markdownFormatItems = [ _FormatToolbarItem( id: 'underline', name: 'underline', - tooltip: - '${AppFlowyEditorL10n.current.underline}${shortcutTooltips('⌘ + U', 'CTRL + U', 'CTRL + U')}', ), _FormatToolbarItem( id: 'bold', name: 'bold', - tooltip: - '${AppFlowyEditorL10n.current.bold}${shortcutTooltips('⌘ + B', 'CTRL + B', 'CTRL + B')}', ), _FormatToolbarItem( id: 'italic', name: 'italic', - tooltip: - '${AppFlowyEditorL10n.current.italic}${shortcutTooltips('⌘ + I', 'CTRL + I', 'CTRL + I')}', ), _FormatToolbarItem( id: 'strikethrough', name: 'strikethrough', - tooltip: - '${AppFlowyEditorL10n.current.strikethrough}${shortcutTooltips('⌘ + SHIFT + S', 'CTRL + SHIFT + S', 'CTRL + SHIFT + S')}', ), _FormatToolbarItem( id: 'code', name: 'code', - tooltip: - '${AppFlowyEditorL10n.current.embedCode}${shortcutTooltips('⌘ + E', 'CTRL + E', 'CTRL + E')}', ), ]; @@ -38,7 +28,6 @@ class _FormatToolbarItem extends ToolbarItem { _FormatToolbarItem({ required String id, required String name, - required String tooltip, }) : super( id: 'editor.$id', group: 2, @@ -56,7 +45,7 @@ class _FormatToolbarItem extends ToolbarItem { isHighlight: isHighlight, highlightColor: highlightColor, iconColor: iconColor, - tooltip: tooltip, + tooltip: getTooltipText(id), onPressed: () => editorState.toggleAttribute(name), ); }, diff --git a/lib/src/editor/toolbar/desktop/items/text_direction_toolbar_items.dart b/lib/src/editor/toolbar/desktop/items/text_direction_toolbar_items.dart index b3533773..7923fe9d 100644 --- a/lib/src/editor/toolbar/desktop/items/text_direction_toolbar_items.dart +++ b/lib/src/editor/toolbar/desktop/items/text_direction_toolbar_items.dart @@ -1,23 +1,21 @@ import 'package:appflowy_editor/appflowy_editor.dart'; +import 'package:appflowy_editor/src/editor/toolbar/desktop/items/utils/tooltip_util.dart'; final List textDirectionItems = [ _TextDirectionToolbarItem( id: 'text_direction_auto', name: blockComponentTextDirectionAuto, - tooltip: AppFlowyEditorL10n.current.auto, iconName: 'text_direction_auto', ), _TextDirectionToolbarItem( id: 'text_direction_ltr', name: blockComponentTextDirectionLTR, - tooltip: AppFlowyEditorL10n.current.ltr, - iconName: 'text_direction_left', + iconName: 'text_direction_ltr', ), _TextDirectionToolbarItem( id: 'text_direction_rtl', name: blockComponentTextDirectionRTL, - tooltip: AppFlowyEditorL10n.current.rtl, - iconName: 'text_direction_right', + iconName: 'text_direction_rtl', ), ]; @@ -25,7 +23,6 @@ class _TextDirectionToolbarItem extends ToolbarItem { _TextDirectionToolbarItem({ required String id, required String name, - required String tooltip, required String iconName, }) : super( id: 'editor.$id', @@ -42,7 +39,7 @@ class _TextDirectionToolbarItem extends ToolbarItem { isHighlight: isHighlight, highlightColor: highlightColor, iconColor: iconColor, - tooltip: tooltip, + tooltip: getTooltipText(id), onPressed: () => editorState.updateNode( selection, (node) => node.copyWith( diff --git a/lib/src/editor/toolbar/desktop/items/utils/tooltip_util.dart b/lib/src/editor/toolbar/desktop/items/utils/tooltip_util.dart index 847a00f3..531e1c24 100644 --- a/lib/src/editor/toolbar/desktop/items/utils/tooltip_util.dart +++ b/lib/src/editor/toolbar/desktop/items/utils/tooltip_util.dart @@ -1,5 +1,6 @@ import 'dart:io'; +import 'package:appflowy_editor/appflowy_editor.dart'; import 'package:flutter/foundation.dart'; String shortcutTooltips( @@ -17,3 +18,32 @@ String shortcutTooltips( } return ''; } + +String getTooltipText(String id) { + switch (id) { + case 'underline': + return '${AppFlowyEditorL10n.current.underline}${shortcutTooltips('⌘ + U', 'CTRL + U', 'CTRL + U')}'; + case 'bold': + return '${AppFlowyEditorL10n.current.bold}${shortcutTooltips('⌘ + B', 'CTRL + B', 'CTRL + B')}'; + case 'italic': + return '${AppFlowyEditorL10n.current.italic}${shortcutTooltips('⌘ + I', 'CTRL + I', 'CTRL + I')}'; + case 'strikethrough': + return '${AppFlowyEditorL10n.current.strikethrough}${shortcutTooltips('⌘ + SHIFT + S', 'CTRL + SHIFT + S', 'CTRL + SHIFT + S')}'; + case 'code': + return '${AppFlowyEditorL10n.current.embedCode}${shortcutTooltips('⌘ + E', 'CTRL + E', 'CTRL + E')}'; + case 'align_left': + return AppFlowyEditorL10n.current.textAlignLeft; + case 'align_center': + return AppFlowyEditorL10n.current.textAlignCenter; + case 'align_right': + return AppFlowyEditorL10n.current.textAlignRight; + case 'text_direction_auto': + return AppFlowyEditorL10n.current.auto; + case 'text_direction_ltr': + return AppFlowyEditorL10n.current.ltr; + case 'text_direction_rtl': + return AppFlowyEditorL10n.current.rtl; + default: + return ''; + } +} diff --git a/lib/src/l10n/intl/messages_en.dart b/lib/src/l10n/intl/messages_en.dart index b1573225..043dda19 100644 --- a/lib/src/l10n/intl/messages_en.dart +++ b/lib/src/l10n/intl/messages_en.dart @@ -55,6 +55,26 @@ class MessageLookup extends MessageLookupByLibrary { "clearHighlightColor": MessageLookupByLibrary.simpleMessage("Clear highlight color"), "closeFind": MessageLookupByLibrary.simpleMessage("Close"), + "cmdDontAddNewLineInTableCell": MessageLookupByLibrary.simpleMessage( + "Don\'t add new line in table cell"), + "cmdMoveToDownCellAtSameOffset": MessageLookupByLibrary.simpleMessage( + "Move to down cell at same offset"), + "cmdMoveToLeftCellIfItsAtStartOfCurrentCell": + MessageLookupByLibrary.simpleMessage( + "Move to left cell if its at start of current cell"), + "cmdMoveToRightCellIfItsAtTheEndOfCurrentCell": + MessageLookupByLibrary.simpleMessage( + "Move to right cell if its at the end of current cell"), + "cmdMoveToUpCellAtSameOffset": MessageLookupByLibrary.simpleMessage( + "Move to up cell at same offset"), + "cmdNavigateAroundTheCellsAtSameOffset": + MessageLookupByLibrary.simpleMessage( + "Navigate around the cells at same offset"), + "cmdNavigateAroundTheCellsAtSameOffsetInReverse": + MessageLookupByLibrary.simpleMessage( + "Navigate around the cells at same offset in reverse"), + "cmdStopAtTheBeginningOfTheCell": MessageLookupByLibrary.simpleMessage( + "Stop at the beginning of the cell"), "colAddAfter": MessageLookupByLibrary.simpleMessage("Add after"), "colAddBefore": MessageLookupByLibrary.simpleMessage("Add before"), "colClear": MessageLookupByLibrary.simpleMessage("Clear Content"), @@ -88,7 +108,7 @@ class MessageLookup extends MessageLookupByLibrary { "hexValue": MessageLookupByLibrary.simpleMessage("Hex value"), "highlight": MessageLookupByLibrary.simpleMessage("Highlight"), "highlightColor": - MessageLookupByLibrary.simpleMessage("Highlight color"), + MessageLookupByLibrary.simpleMessage("Highlight Color"), "image": MessageLookupByLibrary.simpleMessage("Image"), "imageLoadFailed": MessageLookupByLibrary.simpleMessage("Could not load the image"), @@ -109,6 +129,8 @@ class MessageLookup extends MessageLookupByLibrary { "linkText": MessageLookupByLibrary.simpleMessage("Text"), "linkTextHint": MessageLookupByLibrary.simpleMessage("Please enter text"), + "listItemPlaceholder": + MessageLookupByLibrary.simpleMessage("List item"), "loading": MessageLookupByLibrary.simpleMessage("Loading"), "ltr": MessageLookupByLibrary.simpleMessage("LTR"), "mobileHeading1": MessageLookupByLibrary.simpleMessage("Heading 1"), @@ -140,6 +162,9 @@ class MessageLookup extends MessageLookupByLibrary { "strikethrough": MessageLookupByLibrary.simpleMessage("Strikethrough"), "table": MessageLookupByLibrary.simpleMessage("Table"), "text": MessageLookupByLibrary.simpleMessage("Text"), + "textAlignCenter": MessageLookupByLibrary.simpleMessage("Align Center"), + "textAlignLeft": MessageLookupByLibrary.simpleMessage("Align Left"), + "textAlignRight": MessageLookupByLibrary.simpleMessage("Align Right"), "textColor": MessageLookupByLibrary.simpleMessage("Text Color"), "tint1": MessageLookupByLibrary.simpleMessage("Tint 1"), "tint2": MessageLookupByLibrary.simpleMessage("Tint 2"), @@ -150,10 +175,11 @@ class MessageLookup extends MessageLookupByLibrary { "tint7": MessageLookupByLibrary.simpleMessage("Tint 7"), "tint8": MessageLookupByLibrary.simpleMessage("Tint 8"), "tint9": MessageLookupByLibrary.simpleMessage("Tint 9"), + "toDoPlaceholder": MessageLookupByLibrary.simpleMessage("To-do"), "underline": MessageLookupByLibrary.simpleMessage("Underline"), "upload": MessageLookupByLibrary.simpleMessage("Upload"), - "uploadImage": MessageLookupByLibrary.simpleMessage("Upload Image"), + "uploadImage": MessageLookupByLibrary.simpleMessage("Upload"), "urlHint": MessageLookupByLibrary.simpleMessage("URL"), - "urlImage": MessageLookupByLibrary.simpleMessage("URL Image") + "urlImage": MessageLookupByLibrary.simpleMessage("URL") }; } diff --git a/lib/src/l10n/intl/messages_pt-BR.dart b/lib/src/l10n/intl/messages_pt-BR.dart index 22c53407..66dd6e84 100644 --- a/lib/src/l10n/intl/messages_pt-BR.dart +++ b/lib/src/l10n/intl/messages_pt-BR.dart @@ -22,22 +22,173 @@ class MessageLookup extends MessageLookupByLibrary { final messages = _notInlinedMessages(_notInlinedMessages); static Map _notInlinedMessages(_) => { + "addYourLink": + MessageLookupByLibrary.simpleMessage("Adicionar seu link"), + "auto": MessageLookupByLibrary.simpleMessage("Automático"), + "backgroundColor": MessageLookupByLibrary.simpleMessage("Cor de fundo"), + "backgroundColorBlue": + MessageLookupByLibrary.simpleMessage("Fundo azul"), + "backgroundColorBrown": + MessageLookupByLibrary.simpleMessage("Fundo marrom"), + "backgroundColorDefault": + MessageLookupByLibrary.simpleMessage("Fundo padrão"), + "backgroundColorGray": + MessageLookupByLibrary.simpleMessage("Fundo cinza"), + "backgroundColorGreen": + MessageLookupByLibrary.simpleMessage("Fundo verde"), + "backgroundColorOrange": + MessageLookupByLibrary.simpleMessage("Fundo laranja"), + "backgroundColorPink": + MessageLookupByLibrary.simpleMessage("Fundo rosa"), + "backgroundColorPurple": + MessageLookupByLibrary.simpleMessage("Fundo roxo"), + "backgroundColorRed": + MessageLookupByLibrary.simpleMessage("Fundo vermelho\n"), + "backgroundColorYellow": + MessageLookupByLibrary.simpleMessage("Fundo amarelo"), "bold": MessageLookupByLibrary.simpleMessage("Negrito"), "bulletedList": MessageLookupByLibrary.simpleMessage("Lista de marcadores"), + "cancel": MessageLookupByLibrary.simpleMessage("Cancelar"), + "caseSensitive": + MessageLookupByLibrary.simpleMessage("Diferenciar maiúsculas"), "checkbox": MessageLookupByLibrary.simpleMessage("Caixa de seleção"), + "chooseImage": + MessageLookupByLibrary.simpleMessage("Selecionar imagem"), + "clearHighlightColor": + MessageLookupByLibrary.simpleMessage("Limpar cor de destaque"), + "closeFind": MessageLookupByLibrary.simpleMessage("Fechar"), + "cmdDontAddNewLineInTableCell": MessageLookupByLibrary.simpleMessage( + "Não adicionar nova linha na célula"), + "cmdMoveToDownCellAtSameOffset": MessageLookupByLibrary.simpleMessage( + "Mover para a célula abaixo na mesma posição"), + "cmdMoveToLeftCellIfItsAtStartOfCurrentCell": + MessageLookupByLibrary.simpleMessage( + "Mover para a célula à esquerda se estiver no início da célula atual"), + "cmdMoveToRightCellIfItsAtTheEndOfCurrentCell": + MessageLookupByLibrary.simpleMessage( + "Mover para a célula à direita se estiver no final da célula atual"), + "cmdMoveToUpCellAtSameOffset": MessageLookupByLibrary.simpleMessage( + "Mover para a célula acima na mesma posição"), + "cmdNavigateAroundTheCellsAtSameOffset": + MessageLookupByLibrary.simpleMessage( + "Navegar pelas células na mesma posição"), + "cmdNavigateAroundTheCellsAtSameOffsetInReverse": + MessageLookupByLibrary.simpleMessage( + "Navegar pelas células na mesma posição (reverso)"), + "cmdStopAtTheBeginningOfTheCell": + MessageLookupByLibrary.simpleMessage("Parar no início da célula"), + "colAddAfter": + MessageLookupByLibrary.simpleMessage("Inserir à direita"), + "colAddBefore": + MessageLookupByLibrary.simpleMessage("Inserir à esquerda"), + "colClear": MessageLookupByLibrary.simpleMessage("Limpar coluna"), + "colDuplicate": MessageLookupByLibrary.simpleMessage("Duplicar coluna"), + "colRemove": MessageLookupByLibrary.simpleMessage("Deletar coluna"), + "color": MessageLookupByLibrary.simpleMessage("Cor"), + "copy": MessageLookupByLibrary.simpleMessage("Copiar"), + "copyLink": MessageLookupByLibrary.simpleMessage("Copiar link"), + "customColor": + MessageLookupByLibrary.simpleMessage("Cor personalizada"), + "cut": MessageLookupByLibrary.simpleMessage("Cortar"), + "divider": MessageLookupByLibrary.simpleMessage("Separador"), + "done": MessageLookupByLibrary.simpleMessage("Concluir"), + "editLink": MessageLookupByLibrary.simpleMessage("Editar link"), "embedCode": MessageLookupByLibrary.simpleMessage("Código incorporado"), - "heading1": MessageLookupByLibrary.simpleMessage("H1"), - "heading2": MessageLookupByLibrary.simpleMessage("H2"), - "heading3": MessageLookupByLibrary.simpleMessage("H3"), + "emptySearchBoxHint": + MessageLookupByLibrary.simpleMessage("Localizar..."), + "find": MessageLookupByLibrary.simpleMessage("Procurar"), + "fontColorBlue": MessageLookupByLibrary.simpleMessage("Azul"), + "fontColorBrown": MessageLookupByLibrary.simpleMessage("Marrom"), + "fontColorDefault": MessageLookupByLibrary.simpleMessage("Padrão"), + "fontColorGray": MessageLookupByLibrary.simpleMessage("Cinza"), + "fontColorGreen": MessageLookupByLibrary.simpleMessage("Verde"), + "fontColorOrange": MessageLookupByLibrary.simpleMessage("Laranja"), + "fontColorPink": MessageLookupByLibrary.simpleMessage("Rosa"), + "fontColorPurple": MessageLookupByLibrary.simpleMessage("Roxo"), + "fontColorRed": MessageLookupByLibrary.simpleMessage("Vermelho"), + "fontColorYellow": MessageLookupByLibrary.simpleMessage("Amarelo"), + "heading1": MessageLookupByLibrary.simpleMessage("Cabeçalho 1"), + "heading2": MessageLookupByLibrary.simpleMessage("Cabeçalho 2"), + "heading3": MessageLookupByLibrary.simpleMessage("Cabeçalho 3"), + "hexValue": MessageLookupByLibrary.simpleMessage("HEX"), "highlight": MessageLookupByLibrary.simpleMessage("Destacar"), + "highlightColor": + MessageLookupByLibrary.simpleMessage("Cor de destaque"), "image": MessageLookupByLibrary.simpleMessage("Imagem"), + "imageLoadFailed": MessageLookupByLibrary.simpleMessage( + "Não foi possível carregar a imagem"), + "incorrectLink": MessageLookupByLibrary.simpleMessage("Link incorreto"), "italic": MessageLookupByLibrary.simpleMessage("Itálico"), + "lightLightTint1": MessageLookupByLibrary.simpleMessage("Roxo"), + "lightLightTint2": MessageLookupByLibrary.simpleMessage("Rosa"), + "lightLightTint3": MessageLookupByLibrary.simpleMessage("Rosa claro"), + "lightLightTint4": MessageLookupByLibrary.simpleMessage("Laranja"), + "lightLightTint5": MessageLookupByLibrary.simpleMessage("Amarelo"), + "lightLightTint6": MessageLookupByLibrary.simpleMessage("Lima"), + "lightLightTint7": MessageLookupByLibrary.simpleMessage("Verde"), + "lightLightTint8": MessageLookupByLibrary.simpleMessage("Aqua"), + "lightLightTint9": MessageLookupByLibrary.simpleMessage("Azul"), "link": MessageLookupByLibrary.simpleMessage("Link"), + "linkAddressHint": MessageLookupByLibrary.simpleMessage("Insira a URL"), + "linkText": MessageLookupByLibrary.simpleMessage("Texto"), + "linkTextHint": MessageLookupByLibrary.simpleMessage("Insira o rótulo"), + "listItemPlaceholder": + MessageLookupByLibrary.simpleMessage("Item de lista"), + "loading": MessageLookupByLibrary.simpleMessage("Carregando"), + "ltr": MessageLookupByLibrary.simpleMessage("Esquerda para Direita"), + "mobileHeading1": MessageLookupByLibrary.simpleMessage("Cabeçalho 1"), + "mobileHeading2": MessageLookupByLibrary.simpleMessage("Cabeçalho 2"), + "mobileHeading3": MessageLookupByLibrary.simpleMessage("Cabeçalho 3"), + "nextMatch": MessageLookupByLibrary.simpleMessage("Próximo"), + "noFindResult": + MessageLookupByLibrary.simpleMessage("Nenhum resultado encontrado"), "numberedList": MessageLookupByLibrary.simpleMessage("Lista numerada"), - "quote": MessageLookupByLibrary.simpleMessage("Citar"), + "opacity": MessageLookupByLibrary.simpleMessage("Opacidade"), + "openLink": MessageLookupByLibrary.simpleMessage("Abrir link"), + "paste": MessageLookupByLibrary.simpleMessage("Colar"), + "previousMatch": MessageLookupByLibrary.simpleMessage("Anterior"), + "quote": MessageLookupByLibrary.simpleMessage("Citação"), + "regex": MessageLookupByLibrary.simpleMessage("Regex"), + "regexError": MessageLookupByLibrary.simpleMessage("Erro de Regex"), + "removeLink": MessageLookupByLibrary.simpleMessage("Remover link"), + "replace": MessageLookupByLibrary.simpleMessage("Substituir"), + "replaceAll": MessageLookupByLibrary.simpleMessage("Substituir tudo"), + "resetToDefaultColor": + MessageLookupByLibrary.simpleMessage("Redefinir para cor padrão"), + "rowAddAfter": MessageLookupByLibrary.simpleMessage("Inserir abaixo"), + "rowAddBefore": MessageLookupByLibrary.simpleMessage("Inserir acima"), + "rowClear": MessageLookupByLibrary.simpleMessage("Limpar linha"), + "rowDuplicate": MessageLookupByLibrary.simpleMessage("Duplicar linha"), + "rowRemove": MessageLookupByLibrary.simpleMessage("Deletar linha"), + "rtl": MessageLookupByLibrary.simpleMessage("Direita para Esquerda"), + "slashPlaceHolder": MessageLookupByLibrary.simpleMessage( + "Insira / para adicionar um bloco ou comece a escrever"), "strikethrough": MessageLookupByLibrary.simpleMessage("Rasurar"), + "table": MessageLookupByLibrary.simpleMessage("Tabela"), "text": MessageLookupByLibrary.simpleMessage("Texto"), - "underline": MessageLookupByLibrary.simpleMessage("Sublinhar") + "textAlignCenter": + MessageLookupByLibrary.simpleMessage("Alinhar ao centro"), + "textAlignLeft": + MessageLookupByLibrary.simpleMessage("Alinhar à esquerda"), + "textAlignRight": + MessageLookupByLibrary.simpleMessage("Alinhar à direita"), + "textColor": MessageLookupByLibrary.simpleMessage("Cor do texto"), + "tint1": MessageLookupByLibrary.simpleMessage("Matiz 1"), + "tint2": MessageLookupByLibrary.simpleMessage("Matiz 2"), + "tint3": MessageLookupByLibrary.simpleMessage("Matiz 3"), + "tint4": MessageLookupByLibrary.simpleMessage("Matiz 4"), + "tint5": MessageLookupByLibrary.simpleMessage("Matiz 5"), + "tint6": MessageLookupByLibrary.simpleMessage("Matiz 6"), + "tint7": MessageLookupByLibrary.simpleMessage("Matiz 7"), + "tint8": MessageLookupByLibrary.simpleMessage("Matiz 8"), + "tint9": MessageLookupByLibrary.simpleMessage("Matiz 9"), + "toDoPlaceholder": + MessageLookupByLibrary.simpleMessage("Tarefa a fazer"), + "underline": MessageLookupByLibrary.simpleMessage("Sublinhar"), + "upload": MessageLookupByLibrary.simpleMessage("Enviar"), + "uploadImage": MessageLookupByLibrary.simpleMessage("Enviar"), + "urlHint": MessageLookupByLibrary.simpleMessage("URL"), + "urlImage": MessageLookupByLibrary.simpleMessage("URL") }; } diff --git a/lib/src/l10n/intl/messages_pt-PT.dart b/lib/src/l10n/intl/messages_pt-PT.dart index d2d27815..373db006 100644 --- a/lib/src/l10n/intl/messages_pt-PT.dart +++ b/lib/src/l10n/intl/messages_pt-PT.dart @@ -22,22 +22,54 @@ class MessageLookup extends MessageLookupByLibrary { final messages = _notInlinedMessages(_notInlinedMessages); static Map _notInlinedMessages(_) => { + "auto": MessageLookupByLibrary.simpleMessage("Automático"), "bold": MessageLookupByLibrary.simpleMessage("negrito"), "bulletedList": MessageLookupByLibrary.simpleMessage("lista com marcadores"), "checkbox": MessageLookupByLibrary.simpleMessage("caixa de seleção"), + "cmdDontAddNewLineInTableCell": MessageLookupByLibrary.simpleMessage( + "Não adicionar nova linha na célula"), + "cmdMoveToDownCellAtSameOffset": MessageLookupByLibrary.simpleMessage( + "Mover para a célula abaixo na mesma posição"), + "cmdMoveToLeftCellIfItsAtStartOfCurrentCell": + MessageLookupByLibrary.simpleMessage( + "Mover para a célula à esquerda se estiver no início da célula atual"), + "cmdMoveToRightCellIfItsAtTheEndOfCurrentCell": + MessageLookupByLibrary.simpleMessage( + "Mover para a célula à direita se estiver no final da célula atual"), + "cmdMoveToUpCellAtSameOffset": MessageLookupByLibrary.simpleMessage( + "Mover para a célula acima na mesma posição"), + "cmdNavigateAroundTheCellsAtSameOffset": + MessageLookupByLibrary.simpleMessage( + "Navegar pelas células na mesma posição"), + "cmdNavigateAroundTheCellsAtSameOffsetInReverse": + MessageLookupByLibrary.simpleMessage( + "Navegar pelas células na mesma posição (reverso)"), + "cmdStopAtTheBeginningOfTheCell": + MessageLookupByLibrary.simpleMessage("Parar no início da célula"), "embedCode": MessageLookupByLibrary.simpleMessage("Código embutido"), - "heading1": MessageLookupByLibrary.simpleMessage("Cabeçallho 1"), - "heading2": MessageLookupByLibrary.simpleMessage("Cabeçallho 2"), - "heading3": MessageLookupByLibrary.simpleMessage("Cabeçallho 3"), + "heading1": MessageLookupByLibrary.simpleMessage("Cabeçalho 1"), + "heading2": MessageLookupByLibrary.simpleMessage("Cabeçalho 2"), + "heading3": MessageLookupByLibrary.simpleMessage("Cabeçalho 3"), "highlight": MessageLookupByLibrary.simpleMessage("realçar"), + "highlightColor": + MessageLookupByLibrary.simpleMessage("Cor de destaque"), "image": MessageLookupByLibrary.simpleMessage("imagem"), "italic": MessageLookupByLibrary.simpleMessage("itálico"), "link": MessageLookupByLibrary.simpleMessage("link"), + "ltr": MessageLookupByLibrary.simpleMessage("Esquerda para Direita"), "numberedList": MessageLookupByLibrary.simpleMessage("lista numerada"), "quote": MessageLookupByLibrary.simpleMessage("citar"), + "rtl": MessageLookupByLibrary.simpleMessage("Direita para Esquerda"), "strikethrough": MessageLookupByLibrary.simpleMessage("tachado"), "text": MessageLookupByLibrary.simpleMessage("texto"), + "textAlignCenter": + MessageLookupByLibrary.simpleMessage("Alinhar ao centro"), + "textAlignLeft": + MessageLookupByLibrary.simpleMessage("Alinhar à esquerda"), + "textAlignRight": + MessageLookupByLibrary.simpleMessage("Alinhar à direita"), + "textColor": MessageLookupByLibrary.simpleMessage("Cor do texto"), "underline": MessageLookupByLibrary.simpleMessage("sublinhado") }; } diff --git a/lib/src/l10n/l10n.dart b/lib/src/l10n/l10n.dart index f8303ab1..d2e85da3 100644 --- a/lib/src/l10n/l10n.dart +++ b/lib/src/l10n/l10n.dart @@ -621,6 +621,26 @@ class AppFlowyEditorLocalizations { ); } + /// `List item` + String get listItemPlaceholder { + return Intl.message( + 'List item', + name: 'listItemPlaceholder', + desc: '', + args: [], + ); + } + + /// `To-do` + String get toDoPlaceholder { + return Intl.message( + 'To-do', + name: 'toDoPlaceholder', + desc: '', + args: [], + ); + } + /// `URL` String get urlHint { return Intl.message( @@ -761,10 +781,10 @@ class AppFlowyEditorLocalizations { ); } - /// `Highlight color` + /// `Highlight Color` String get highlightColor { return Intl.message( - 'Highlight color', + 'Highlight Color', name: 'highlightColor', desc: '', args: [], @@ -991,20 +1011,20 @@ class AppFlowyEditorLocalizations { ); } - /// `Upload Image` + /// `Upload` String get uploadImage { return Intl.message( - 'Upload Image', + 'Upload', name: 'uploadImage', desc: '', args: [], ); } - /// `URL Image` + /// `URL` String get urlImage { return Intl.message( - 'URL Image', + 'URL', name: 'urlImage', desc: '', args: [], @@ -1190,6 +1210,116 @@ class AppFlowyEditorLocalizations { args: [], ); } + + /// `Align Left` + String get textAlignLeft { + return Intl.message( + 'Align Left', + name: 'textAlignLeft', + desc: '', + args: [], + ); + } + + /// `Align Center` + String get textAlignCenter { + return Intl.message( + 'Align Center', + name: 'textAlignCenter', + desc: '', + args: [], + ); + } + + /// `Align Right` + String get textAlignRight { + return Intl.message( + 'Align Right', + name: 'textAlignRight', + desc: '', + args: [], + ); + } + + /// `Don't add new line in table cell` + String get cmdDontAddNewLineInTableCell { + return Intl.message( + 'Don\'t add new line in table cell', + name: 'cmdDontAddNewLineInTableCell', + desc: '', + args: [], + ); + } + + /// `Move to left cell if its at start of current cell` + String get cmdMoveToLeftCellIfItsAtStartOfCurrentCell { + return Intl.message( + 'Move to left cell if its at start of current cell', + name: 'cmdMoveToLeftCellIfItsAtStartOfCurrentCell', + desc: '', + args: [], + ); + } + + /// `Move to right cell if its at the end of current cell` + String get cmdMoveToRightCellIfItsAtTheEndOfCurrentCell { + return Intl.message( + 'Move to right cell if its at the end of current cell', + name: 'cmdMoveToRightCellIfItsAtTheEndOfCurrentCell', + desc: '', + args: [], + ); + } + + /// `Move to up cell at same offset` + String get cmdMoveToUpCellAtSameOffset { + return Intl.message( + 'Move to up cell at same offset', + name: 'cmdMoveToUpCellAtSameOffset', + desc: '', + args: [], + ); + } + + /// `Move to down cell at same offset` + String get cmdMoveToDownCellAtSameOffset { + return Intl.message( + 'Move to down cell at same offset', + name: 'cmdMoveToDownCellAtSameOffset', + desc: '', + args: [], + ); + } + + /// `Navigate around the cells at same offset` + String get cmdNavigateAroundTheCellsAtSameOffset { + return Intl.message( + 'Navigate around the cells at same offset', + name: 'cmdNavigateAroundTheCellsAtSameOffset', + desc: '', + args: [], + ); + } + + /// `Navigate around the cells at same offset in reverse` + String get cmdNavigateAroundTheCellsAtSameOffsetInReverse { + return Intl.message( + 'Navigate around the cells at same offset in reverse', + name: 'cmdNavigateAroundTheCellsAtSameOffsetInReverse', + desc: '', + args: [], + ); + } + + /// `Stop at the beginning of the cell` + String get cmdStopAtTheBeginningOfTheCell { + return Intl.message( + 'Stop at the beginning of the cell', + name: 'cmdStopAtTheBeginningOfTheCell', + desc: '', + args: [], + ); + } } class AppLocalizationDelegate diff --git a/lib/src/service/context_menu/built_in_context_menu_item.dart b/lib/src/service/context_menu/built_in_context_menu_item.dart index fc3a6c8c..c8d1a259 100644 --- a/lib/src/service/context_menu/built_in_context_menu_item.dart +++ b/lib/src/service/context_menu/built_in_context_menu_item.dart @@ -7,21 +7,21 @@ final standardContextMenuItems = [ [ // cut ContextMenuItem( - name: AppFlowyEditorL10n.current.cut, + getName: () => AppFlowyEditorL10n.current.cut, onPressed: (editorState) { handleCut(editorState); }, ), // copy ContextMenuItem( - name: AppFlowyEditorL10n.current.copy, + getName: () => AppFlowyEditorL10n.current.copy, onPressed: (editorState) { handleCopy(editorState); }, ), // Paste ContextMenuItem( - name: AppFlowyEditorL10n.current.paste, + getName: () => AppFlowyEditorL10n.current.paste, onPressed: (editorState) { handlePaste(editorState); }, diff --git a/lib/src/service/context_menu/context_menu.dart b/lib/src/service/context_menu/context_menu.dart index 99319e0d..9af2070a 100644 --- a/lib/src/service/context_menu/context_menu.dart +++ b/lib/src/service/context_menu/context_menu.dart @@ -3,14 +3,16 @@ import 'package:flutter/material.dart'; class ContextMenuItem { ContextMenuItem({ - required this.name, + required String Function() getName, required this.onPressed, this.isApplicable, - }); + }) : _getName = getName; - final String name; + final String Function() _getName; final void Function(EditorState editorState) onPressed; final bool Function(EditorState editorState)? isApplicable; + + String get name => _getName(); } class ContextMenu extends StatelessWidget { diff --git a/test/editor/block_component/image_block_component/image_upload_widget_test.dart b/test/editor/block_component/image_block_component/image_upload_widget_test.dart index 0413d842..2f71978b 100644 --- a/test/editor/block_component/image_block_component/image_upload_widget_test.dart +++ b/test/editor/block_component/image_block_component/image_upload_widget_test.dart @@ -33,14 +33,14 @@ void main() { ), ); - final urlButtonFinder = find.widgetWithText(Tab, 'URL Image'); + final urlButtonFinder = find.widgetWithText(Tab, 'URL'); expect(urlButtonFinder, findsOneWidget); await tester.tap(urlButtonFinder); await tester.pumpAndSettle(); final urlFieldFinder = find.widgetWithText(TextField, 'URL'); expect(urlFieldFinder, findsOneWidget); await tester.enterText(urlFieldFinder, 'Hello World!'); - final uploadButtonFinder = find.text('Upload'); + final uploadButtonFinder = find.widgetWithText(TextButton, 'Upload'); expect(uploadButtonFinder, findsOneWidget); await tester.tap(uploadButtonFinder); await tester.pumpAndSettle();