Let's handle these changes in another PR.
Except the modifications in the prompt, this translate.py is now in sync with the translate.py in update-translations-prompt (#13968).
Exchange rule 4 and 5 and then exclude additional abbr's (abbr's without an english equivalent) from the list of abbr's which shall always be updated, as the LLM has nothing to diff against in this case. There were cases where it removed good information, which I had to undo, see e.g. the changes in `tutorial\query-param-models.md` in the two previous commits.
After these changes it now seems to handle descriptions in title attributes well, both when translating a document the first time – see the abbr section in the `ru/docs/_llm-test.md` which I committed for reference, but I am not sure if everything is correct there, as I do not speak Russian – and when updating translations – tested with e.g. `ru/docs/features.md` and `ru/docs/tutorial/path-params-numeric-validations.md`, not committed.
I simplified rule 3 to just match when the separator is a colon (`:`), not when it is a comma (`,`), there are otherwise too many cases it may misunderstand, as commas are regularly used in title attributes. Updated the two instances in the English docs (`features.md` and `tutorial\sql-databases.md`) where a comma was used instead of a colon in a case, which we match with rule 3. I fixed the results in schemes they accidentally had `(de)` appended, but they are language independent.
I noticed that it forgot to remove a removed sentence and to add an added part of a sentence, when I reordered/updated a few sentences in the test file. It was stubborn even when retranslating. After these reformulations and the the added sentence at the end it saw these changes and properly synced them.
This is also cleanup for the abbr issue, not directly related.
... making a few fixes/changes:
* Fix a deprecation warning
* Fix a probably not intended hardcoded "es" language identifier when calling `translate_page`
* Fix `iter_en_paths_to_translate` and `non_translated_sections ` to also work on Windows, which uses backslashes in stringified paths
* Add `mode`, `verbose` and `preview` parameters to `translate_lang`, add a helper function to print path infos, and improve its output to show the progress.
* Add documentation to some function parameters
This commit started as an attempt to handle translation of abbr elements, which I was not able to get to work in a clean way. Shortly before I resigned I had the idea to try `openai:gpt-5` as agent in the translate.py, instead of `openai:gpt-4o` and BAM it worked. A lot of other things also worked much better. Modifications had to be made though because GPT-5 interpreted some rules stricter, so some reformulation and some more examples were needed. Will translate with that agent in the remaining translations to test if these prompts work well.
As it did so once (like in the example). This is actually super smart, the anchor exists (is the LLM caching the Anchors of headings in other documents?!), but I guess this possibly creates confusion, so avoid.
..., which tells the LLM to fix wrongly translated anchor parts in links.
Back in those days I translated these parts, to link to the correct German heading, which then had a different anchor than the English heading. But now, as we use the same anchors
documentation-wide, this needs to be undone. The LLM missed some of these translated anchors, so I added this rule.
I will check via script, when gone through the whole documentation, if all those anchor parts are in sync and valid.
In this document it added language codes to urls starting with "https://sqlmodel.tiangolo.com/", resulting in broken links.
So I changed the instructions in the translate.py, so that it only adds the language code when the URL starts exactly with "https://fastapi.tiangolo.com".