Skip to content

Commit 16cf7d2

Browse files
sjsyrekclaude
andcommitted
docs(examples): update glossary example for v3 API
Comprehensive update to examples/03-glossaries.sh to reflect v3 API functionality and best practices after validation. Changes: - Update title and description to mention v3 API support - Add better organization with section headers - Add example #7-8: Rename glossary and verify - Add example #9: Translate with and without glossary to show the difference - Add example #10: List supported glossary language pairs - Fix --from flag requirement for glossary translation - Add comprehensive tips section explaining: - Multilingual glossary support in v3 - When to use glossaries (product names, technical terms, etc.) - How to use --target-lang flag for multilingual glossaries - Change glossary names to avoid conflicts (add -demo suffix) - Improve output formatting and educational content All examples tested and working correctly with v3 API. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 8878ba2 commit 16cf7d2

1 file changed

Lines changed: 67 additions & 27 deletions

File tree

examples/03-glossaries.sh

Lines changed: 67 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
#!/bin/bash
2-
# Example 3: Glossaries
2+
# Example 3: Glossaries (v3 API)
33
# Demonstrates managing glossaries for consistent terminology
4+
# v3 API supports both single-target and multilingual glossaries
45

56
set -e # Exit on error
67

7-
echo "=== DeepL CLI Example 3: Glossaries ==="
8+
echo "=== DeepL CLI Example 3: Glossaries (v3 API) ==="
89
echo
910

1011
# Check if API key is configured
@@ -46,14 +47,18 @@ EOF
4647
echo "✓ Sample glossary files created"
4748
echo
4849

50+
# ═══════════════════════════════════════════════════════
51+
# BASIC GLOSSARY OPERATIONS
52+
# ═══════════════════════════════════════════════════════
53+
4954
# Example 1: Create a glossary
5055
echo "1. Create tech glossary (EN → DE)"
51-
deepl glossary create tech-terms en de "$SAMPLE_DIR/tech-glossary.tsv"
56+
deepl glossary create tech-terms-demo en de "$SAMPLE_DIR/tech-glossary.tsv"
5257
echo
5358

5459
# Example 2: Create another glossary
5560
echo "2. Create business glossary (EN → ES)"
56-
deepl glossary create business-terms en es "$SAMPLE_DIR/business-glossary.tsv"
61+
deepl glossary create business-terms-demo en es "$SAMPLE_DIR/business-glossary.tsv"
5762
echo
5863

5964
# Example 3: List all glossaries
@@ -63,40 +68,68 @@ echo
6368

6469
# Example 4: Show glossary details
6570
echo "4. Show tech glossary details"
66-
deepl glossary show tech-terms
71+
deepl glossary show tech-terms-demo
6772
echo
6873

6974
# Example 5: View glossary entries
7075
echo "5. View tech glossary entries"
71-
deepl glossary entries tech-terms
76+
deepl glossary entries tech-terms-demo
7277
echo
7378

7479
# Example 6: View business glossary entries
7580
echo "6. View business glossary entries"
76-
deepl glossary entries business-terms
81+
deepl glossary entries business-terms-demo
7782
echo
7883

79-
# Example 7: Find glossary by ID (get ID from list)
80-
echo "7. Find glossary by ID"
81-
GLOSSARY_ID=$(deepl glossary list 2>/dev/null | grep -A 1 "tech-terms" | grep "ID:" | awk '{print $2}' | head -1)
82-
if [ -n "$GLOSSARY_ID" ]; then
83-
echo " Looking up glossary with ID: $GLOSSARY_ID"
84-
deepl glossary show "$GLOSSARY_ID"
85-
fi
84+
# Example 7: Rename a glossary
85+
echo "7. Rename glossary"
86+
deepl glossary rename tech-terms-demo tech-terms-renamed
87+
echo "✓ Renamed tech-terms-demo to tech-terms-renamed"
88+
echo
89+
90+
# Example 8: Verify rename
91+
echo "8. Verify rename"
92+
deepl glossary show tech-terms-renamed
8693
echo
8794

88-
# Cleanup: Delete glossaries
89-
echo "8. Clean up - delete glossaries"
90-
echo " Deleting tech-terms..."
91-
deepl glossary delete tech-terms 2>/dev/null || echo " (Already deleted)"
95+
# ═══════════════════════════════════════════════════════
96+
# USING GLOSSARIES IN TRANSLATION
97+
# ═══════════════════════════════════════════════════════
9298

93-
echo " Deleting business-terms..."
94-
deepl glossary delete business-terms 2>/dev/null || echo " (Already deleted)"
99+
echo "9. Translate with glossary"
100+
echo " Without glossary:"
101+
deepl translate "The API endpoint requires authentication." --from en --to de
102+
103+
echo
104+
echo " With tech glossary:"
105+
deepl translate "The API endpoint requires authentication." --from en --to de --glossary tech-terms-renamed
106+
107+
echo
108+
109+
# ═══════════════════════════════════════════════════════
110+
# GLOSSARY LANGUAGE PAIRS
111+
# ═══════════════════════════════════════════════════════
112+
113+
echo "10. List supported glossary language pairs"
114+
deepl glossary languages | head -10
115+
echo " (showing first 10 pairs - see 'deepl glossary languages' for full list)"
116+
echo
117+
118+
# ═══════════════════════════════════════════════════════
119+
# CLEANUP
120+
# ═══════════════════════════════════════════════════════
121+
122+
echo "11. Clean up - delete glossaries"
123+
echo " Deleting tech-terms-renamed..."
124+
deepl glossary delete tech-terms-renamed 2>/dev/null || echo " (Already deleted)"
125+
126+
echo " Deleting business-terms-demo..."
127+
deepl glossary delete business-terms-demo 2>/dev/null || echo " (Already deleted)"
95128

96129
echo
97130

98131
# Verify deletion
99-
echo "9. Verify glossaries are deleted"
132+
echo "12. Verify glossaries are deleted"
100133
deepl glossary list
101134
echo
102135

@@ -107,9 +140,16 @@ echo "✓ Cleanup complete"
107140

108141
echo "=== All glossary examples completed! ==="
109142
echo
110-
echo "💡 Tip: Glossaries ensure consistent translation of technical terms across your project."
111-
echo " Use them for:"
112-
echo " - Product names"
113-
echo " - Technical terminology"
114-
echo " - Brand-specific terms"
115-
echo " - Domain-specific vocabulary"
143+
echo "💡 Glossary Tips:"
144+
echo " ✓ Glossaries ensure consistent translation of technical terms"
145+
echo " ✓ v3 API supports multilingual glossaries (multiple target languages)"
146+
echo " ✓ Use glossaries for:"
147+
echo " - Product names (e.g., 'iPhone' should not be translated)"
148+
echo " - Technical terminology (e.g., 'API', 'endpoint', 'authentication')"
149+
echo " - Brand-specific terms (e.g., company name, product features)"
150+
echo " - Domain-specific vocabulary (e.g., legal, medical, financial terms)"
151+
echo
152+
echo " ✓ For multilingual glossaries, use --target-lang flag to specify"
153+
echo " which language pair to view/modify:"
154+
echo " deepl glossary entries my-glossary --target de"
155+
echo " deepl glossary add-entry my-glossary 'source' 'target' --target-lang de"

0 commit comments

Comments
 (0)