|
121 | 121 | 7. Do not transliterate or explain translations. |
122 | 122 | 8. Output must be entirely in the target_language except preserved placeholders. |
123 | 123 | 9. Output must be valid JSON. |
124 | | -10. Output must be a single JSON array of strings. |
| 124 | +10. Output must be a single JSON array containing only JSON strings. |
125 | 125 | 11. Do not include markdown code fences or any additional text. |
126 | | -12. The number of output elements must exactly match the number of input strings. Do not emit empty extra strings. |
| 126 | +12. The number of output elements must exactly match the number of input strings. Do not emit empty extra strings, objects, diagnostics, explanations, or metadata. |
127 | 127 | 13. Ensure all output strings are properly JSON-escaped. |
128 | 128 | 14. Internally verify placeholder integrity and JSON validity before responding. |
129 | 129 | 15. Placeholder contract: Tokens like @@PH44@@ are opaque atoms. Never translate, inflect, split, rename, reorder characters inside, wrap, or escape them. Never convert them to another syntax. |
130 | 130 | 16. Markup contract: Preserve markup, tags, attributes, entities, and similar control sequences exactly. Translate only human-readable text outside markup and outside placeholder tokens. |
131 | 131 | 17. Output contract: Return exactly one JSON array of strings, with no characters before `[` or after `]`. |
132 | | -18. Treat context, key, explanation, secondary, plural, failing_checks, and placeholders fields as reference material only. Do not translate them directly and do not add their contents unless they are present in source. |
| 132 | +18. Treat context, key, explanation, secondary, plural, failing_checks, and placeholders fields as reference material only. Do not translate them directly and do not add, copy, or emit their contents unless they are present in source. |
133 | 133 | 19. Placeholder mappings explain what opaque placeholder tokens represent. This information may guide wording, but the output must still contain the exact placeholder tokens, not the mapped content. |
134 | | -20. Failing checks describe issues to avoid or fix when improving an existing translation. |
| 134 | +20. Failing checks describe issues to avoid or fix when improving an existing translation. They are context only; do not include their check_id, name, description, or generated diagnostics in output. |
135 | 135 | 21. Target-language project instructions, when present above, contain additional requirements for the target language. Follow them unless they conflict with preserving the source meaning, placeholders, markup, or output contract. |
136 | 136 | 22. For translatable markup placeholders that wrap text, translate the whole text between the placeholders. Example: @@PH1@@Reset and reapply@@PH2@@ can become @@PH1@@Zurucksetzen und erneut anwenden@@PH2@@, never @@PH1@@Zurucksetzen und @@PH2@@erneut anwenden@@PH2@@. |
137 | 137 |
|
|
141 | 141 | Invalid placeholder handling: |
142 | 142 | ["Click <a href=\"/x\">log out</a> and use \\@\\@PH195\\@\\@."] |
143 | 143 |
|
144 | | -Respond ONLY with a valid JSON array of strings, one per input string, in the same order: |
| 144 | +Respond ONLY with a valid JSON array of strings, one per input string, in the same order. Do not include JSON objects or any values other than strings: |
145 | 145 |
|
146 | 146 | ["translation 1", "translation 2", ...] |
147 | 147 | """ |
@@ -248,6 +248,14 @@ def fetch_llm_translations( |
248 | 248 | ) -> str | None: |
249 | 249 | raise NotImplementedError |
250 | 250 |
|
| 251 | + def get_model(self) -> str: |
| 252 | + raise NotImplementedError |
| 253 | + |
| 254 | + def get_traced_model(self) -> str: |
| 255 | + model = self.get_model() |
| 256 | + add_breadcrumb(self.name, "model", model=model) |
| 257 | + return model |
| 258 | + |
251 | 259 | @staticmethod |
252 | 260 | def _normalize_context_text(text: str | None) -> str: |
253 | 261 | if text is None: |
@@ -1515,8 +1523,11 @@ def _normalize_translations( |
1515 | 1523 | if ( |
1516 | 1524 | isinstance(translations, list) |
1517 | 1525 | and len(translations) > expected_length |
1518 | | - and all(isinstance(item, str) for item in translations) |
1519 | | - and not any(translations[expected_length:]) |
| 1526 | + and all(isinstance(item, str) for item in translations[:expected_length]) |
| 1527 | + and not any( |
| 1528 | + isinstance(item, str) and item |
| 1529 | + for item in translations[expected_length:] |
| 1530 | + ) |
1520 | 1531 | ): |
1521 | 1532 | return translations[:expected_length] |
1522 | 1533 | return translations |
|
0 commit comments