You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**Translate gettext (.po) files using AI models.** Supports OpenAI, Azure OpenAI, Anthropic/Claude, DeepSeek, and Ollama (local) with automatic AI translation tagging.
7
+
**Translate gettext (.po) files using AI models.** Supports OpenAI, Azure OpenAI, Anthropic/Claude, and DeepSeek with automatic AI translation tagging and context-aware translations.
# For non-Latin scripts, use qwen2.5 WITHOUT --bulk
88
-
gpt-po-translator --provider ollama --model qwen2.5 --folder ./locales --lang ar
89
-
```
90
-
91
-
> **💡 Important:** For Ollama with **non-Latin languages** (Arabic, Chinese, Japanese, etc.), **omit the `--bulk` flag**. Single-item translation is more reliable because the model doesn't have to format responses as JSON.
Copy file name to clipboardExpand all lines: docs/usage.md
+49Lines changed: 49 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -751,6 +751,55 @@ Both modes use the same preservation logic, ensuring consistent behavior.
751
751
752
752
---
753
753
754
+
## Context-Aware Translations with msgctxt
755
+
756
+
### Overview
757
+
758
+
The tool automatically uses `msgctxt` (message context) from PO entries to provide context to the AI, improving translation accuracy for ambiguous terms.
759
+
760
+
### How It Works
761
+
762
+
When a PO entry includes `msgctxt`, it's automatically passed to the AI:
763
+
764
+
```po
765
+
msgctxt "button"
766
+
msgid "Save"
767
+
msgstr ""
768
+
```
769
+
770
+
The AI receives:
771
+
```
772
+
CONTEXT: button
773
+
IMPORTANT: Choose the translation that matches this specific context and usage.
774
+
775
+
Translate to German: Save
776
+
```
777
+
778
+
Result: **"Speichern"** (button action) instead of **"Sparen"** (to save money)
779
+
780
+
### Best Practices
781
+
782
+
**✓ Good - Detailed, Explicit Context:**
783
+
```po
784
+
msgctxt "status: not Halten (verb), but Angehalten/Wartend (state)"
785
+
msgid "Hold"
786
+
msgstr "" → "Angehalten" ✓
787
+
```
788
+
789
+
**⚠️ Limited - Simple Context:**
790
+
```po
791
+
msgctxt "status"
792
+
msgid "Hold"
793
+
msgstr "" → "Halten" (may still be wrong)
794
+
```
795
+
796
+
**Key Points:**
797
+
-**Be explicit** - Describe what you want AND what you don't want
798
+
-**Provide examples** - Include similar terms or expected word forms
799
+
-**Human review still needed** - msgctxt improves results but doesn't guarantee perfection
800
+
801
+
---
802
+
754
803
## Behind the Scenes: API Calls and Post-Processing
0 commit comments