-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path01-basic-translation.sh
More file actions
executable file
·75 lines (60 loc) · 2.24 KB
/
01-basic-translation.sh
File metadata and controls
executable file
·75 lines (60 loc) · 2.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/bash
# Example 1: Basic Translation
# Demonstrates simple text translation with various options
set -e # Exit on error
echo "=== DeepL CLI Example 1: Basic Translation ==="
echo
# Check if API key is configured
if ! deepl auth show &>/dev/null; then
echo "❌ Error: API key not configured"
echo "Run: deepl auth set-key YOUR_API_KEY"
exit 1
fi
echo "✓ API key configured"
echo
# Example 1: Simple translation
echo "1. Simple translation (English → Spanish)"
deepl translate "Hello, world!" --to es
echo
# Example 2: Auto-detect source language
echo "2. Auto-detect source language (French → English)"
deepl translate "Bonjour, comment allez-vous?" --to en
echo
# Example 3: Specify source language explicitly
echo "3. Explicit source language (German → English)"
deepl translate "Guten Tag" --from de --to en
echo
# Example 4: Multiple target languages
echo "4. Multiple target languages (English → ES, FR, DE)"
deepl translate "Good morning" --to es,fr,de
echo
# Example 5: Formality levels
echo "5a. Formal translation (English → German, more formal)"
deepl translate "How are you?" --formality more --to de
echo
echo "5b. Informal translation (English → German, less formal)"
deepl translate "How are you?" --formality less --to de
echo
echo "5c. Prefer formal (soft preference - degrades gracefully for unsupported languages):"
deepl translate "How are you?" --formality prefer_more --to de
echo
echo "5d. Prefer informal (soft preference):"
deepl translate "How are you?" --formality prefer_less --to de
echo
# Example 6: Reading from stdin
echo "6. Reading from stdin"
echo "This is a test message" | deepl translate --to ja
echo
# Example 7: Long text
echo "7. Translating longer text"
deepl translate "The quick brown fox jumps over the lazy dog. This is a common English pangram used for testing." --to es
echo
# Example 8: Control sentence splitting
echo "8. Control sentence splitting"
echo "8a. Split sentences OFF (treat input as single unit):"
deepl translate "First sentence. Second sentence. Third sentence." --to es --split-sentences off
echo
echo "8b. No splitting on newlines:"
printf "Line one.\nLine two.\nLine three." | deepl translate --to es --split-sentences nonewlines
echo
echo "=== All examples completed successfully! ==="