|
| 1 | +import { GoogleTranslateIcon } from '@/components/icons' |
| 2 | +import { AuthMode, type BlockConfig } from '@/blocks/types' |
| 3 | + |
| 4 | +export const GoogleTranslateBlock: BlockConfig = { |
| 5 | + type: 'google_translate', |
| 6 | + name: 'Google Translate', |
| 7 | + description: 'Translate text using Google Cloud Translation', |
| 8 | + longDescription: |
| 9 | + 'Translate and detect languages using the Google Cloud Translation API. Supports auto-detection of the source language.', |
| 10 | + docsLink: 'https://docs.sim.ai/tools/google_translate', |
| 11 | + category: 'tools', |
| 12 | + bgColor: '#E0E0E0', |
| 13 | + icon: GoogleTranslateIcon, |
| 14 | + authMode: AuthMode.ApiKey, |
| 15 | + subBlocks: [ |
| 16 | + { |
| 17 | + id: 'operation', |
| 18 | + title: 'Operation', |
| 19 | + type: 'dropdown', |
| 20 | + options: [ |
| 21 | + { label: 'Translate Text', id: 'text' }, |
| 22 | + { label: 'Detect Language', id: 'detect' }, |
| 23 | + ], |
| 24 | + value: () => 'text', |
| 25 | + }, |
| 26 | + { |
| 27 | + id: 'text', |
| 28 | + title: 'Text', |
| 29 | + type: 'long-input', |
| 30 | + placeholder: 'Enter text...', |
| 31 | + required: true, |
| 32 | + }, |
| 33 | + { |
| 34 | + id: 'target', |
| 35 | + title: 'Target Language', |
| 36 | + type: 'dropdown', |
| 37 | + condition: { field: 'operation', value: 'text' }, |
| 38 | + options: [ |
| 39 | + { label: 'English', id: 'en' }, |
| 40 | + { label: 'Spanish', id: 'es' }, |
| 41 | + { label: 'French', id: 'fr' }, |
| 42 | + { label: 'German', id: 'de' }, |
| 43 | + { label: 'Italian', id: 'it' }, |
| 44 | + { label: 'Portuguese', id: 'pt' }, |
| 45 | + { label: 'Russian', id: 'ru' }, |
| 46 | + { label: 'Japanese', id: 'ja' }, |
| 47 | + { label: 'Korean', id: 'ko' }, |
| 48 | + { label: 'Chinese (Simplified)', id: 'zh-CN' }, |
| 49 | + { label: 'Chinese (Traditional)', id: 'zh-TW' }, |
| 50 | + { label: 'Arabic', id: 'ar' }, |
| 51 | + { label: 'Hindi', id: 'hi' }, |
| 52 | + { label: 'Turkish', id: 'tr' }, |
| 53 | + { label: 'Dutch', id: 'nl' }, |
| 54 | + { label: 'Polish', id: 'pl' }, |
| 55 | + { label: 'Swedish', id: 'sv' }, |
| 56 | + { label: 'Thai', id: 'th' }, |
| 57 | + { label: 'Vietnamese', id: 'vi' }, |
| 58 | + { label: 'Indonesian', id: 'id' }, |
| 59 | + { label: 'Ukrainian', id: 'uk' }, |
| 60 | + { label: 'Czech', id: 'cs' }, |
| 61 | + { label: 'Greek', id: 'el' }, |
| 62 | + { label: 'Hebrew', id: 'he' }, |
| 63 | + { label: 'Romanian', id: 'ro' }, |
| 64 | + { label: 'Hungarian', id: 'hu' }, |
| 65 | + { label: 'Danish', id: 'da' }, |
| 66 | + { label: 'Finnish', id: 'fi' }, |
| 67 | + { label: 'Norwegian', id: 'no' }, |
| 68 | + { label: 'Bengali', id: 'bn' }, |
| 69 | + { label: 'Malay', id: 'ms' }, |
| 70 | + { label: 'Filipino', id: 'tl' }, |
| 71 | + { label: 'Swahili', id: 'sw' }, |
| 72 | + { label: 'Urdu', id: 'ur' }, |
| 73 | + ], |
| 74 | + value: () => 'es', |
| 75 | + required: { field: 'operation', value: 'text' }, |
| 76 | + }, |
| 77 | + { |
| 78 | + id: 'source', |
| 79 | + title: 'Source Language', |
| 80 | + type: 'dropdown', |
| 81 | + condition: { field: 'operation', value: 'text' }, |
| 82 | + options: [ |
| 83 | + { label: 'Auto-detect', id: '' }, |
| 84 | + { label: 'English', id: 'en' }, |
| 85 | + { label: 'Spanish', id: 'es' }, |
| 86 | + { label: 'French', id: 'fr' }, |
| 87 | + { label: 'German', id: 'de' }, |
| 88 | + { label: 'Italian', id: 'it' }, |
| 89 | + { label: 'Portuguese', id: 'pt' }, |
| 90 | + { label: 'Russian', id: 'ru' }, |
| 91 | + { label: 'Japanese', id: 'ja' }, |
| 92 | + { label: 'Korean', id: 'ko' }, |
| 93 | + { label: 'Chinese (Simplified)', id: 'zh-CN' }, |
| 94 | + { label: 'Chinese (Traditional)', id: 'zh-TW' }, |
| 95 | + { label: 'Arabic', id: 'ar' }, |
| 96 | + { label: 'Hindi', id: 'hi' }, |
| 97 | + { label: 'Turkish', id: 'tr' }, |
| 98 | + { label: 'Dutch', id: 'nl' }, |
| 99 | + { label: 'Polish', id: 'pl' }, |
| 100 | + ], |
| 101 | + value: () => '', |
| 102 | + }, |
| 103 | + { |
| 104 | + id: 'apiKey', |
| 105 | + title: 'API Key', |
| 106 | + type: 'short-input', |
| 107 | + placeholder: 'Enter your Google Cloud API key', |
| 108 | + password: true, |
| 109 | + required: true, |
| 110 | + }, |
| 111 | + ], |
| 112 | + tools: { |
| 113 | + access: ['google_translate_text', 'google_translate_detect'], |
| 114 | + config: { |
| 115 | + tool: (params) => `google_translate_${params.operation}`, |
| 116 | + }, |
| 117 | + }, |
| 118 | + inputs: { |
| 119 | + text: { type: 'string', description: 'Text to translate or detect language of' }, |
| 120 | + target: { type: 'string', description: 'Target language code' }, |
| 121 | + source: { type: 'string', description: 'Source language code (optional, auto-detected)' }, |
| 122 | + apiKey: { type: 'string', description: 'Google Cloud API key' }, |
| 123 | + }, |
| 124 | + outputs: { |
| 125 | + translatedText: { type: 'string', description: 'Translated text' }, |
| 126 | + detectedSourceLanguage: { type: 'string', description: 'Detected source language code' }, |
| 127 | + language: { type: 'string', description: 'Detected language code' }, |
| 128 | + confidence: { type: 'number', description: 'Detection confidence score' }, |
| 129 | + }, |
| 130 | +} |
0 commit comments