Browse Source

Update prompts

pull/14015/head
Nils Lindemann 1 week ago
parent
commit
018f8523ff
  1. 497
      docs/de/llm-prompt.md
  2. 343
      scripts/translate.py

497
docs/de/llm-prompt.md

@ -1,422 +1,345 @@
1) Translate to German (Deutsch). ### Target language
Translate to German (Deutsch).
Language code: de. Language code: de.
2) Use the formal grammar (use `Sie` instead of `Du`). ### Definitions
hyphen
The character «-»
Unicode U+002D (HYPHEN-MINUS)
Alternative names: hyphen, dash, minus sign
3) Convert quotation marks (") to typographic quotation marks („“). dash
The character «–»
Unicode U+2013 (EN DASH)
German name: Halbgeviertstrich
Example:
### Grammar to use when talking to the reader
Use the formal grammar (use «Sie» instead of «Du»).
### Quotes
1) Convert neutral double quotes («"» and «"») and English double typographic quotes («“» and «”») to German double typographic quotes («„» and «“»). Convert neutral single quotes («'» and «'») and English single typographic quotes («‘» and «’») to German single typographic quotes («‚» and «‘»).
Examples:
Source (English): Source (English):
«««
"Hello world" "Hello world"
“Hello Universe”
"He said: 'Hello'"
“my name is ‘Nils’”
»»»
Result (German): Result (German):
«««
„Hallo Welt“ „Hallo Welt“
„Hallo Universum“
„Er sagte: ‚Hallo‘“
„Mein Name ist ‚Nils‘“
»»»
3.1) Inside inline code (= surrounded by backticks), leave quotation marks (") as is, as they usually mark string literals and typographic quotation marks („“) can not be used for that. 2) Inside code snippets and code blocks, leave neutral double quotes («"») and neutral single quotes («'») AS IS. Do NOT convert them to typographic quotes.
Example: Example:
Source (English) – contains four inline codes, three of them contain a string literal: Source (English) – contains four code snippets, three of them contain a string literal:
«««
Inline code: `i am inline code` Inline code: `i am inline code`
Inline code containing a string literal: `i am inline code "I am a string literal"` Inline code containing a string literal: `i am inline code "I am a string literal"`
Inline code containing only a short string literal: `"foo"` Inline code containing only a short string literal: `"foo"`
`"__main__"` `"__main__"`
`"fastapi[standard]"`
»»»
Result (German) – as all the quotation marks (") are inside inline code, you keep them as is, as you always should with content inside inline code: Result (German) – as all the quotes («"») are inside code snippets («`...`»), you keep them as is (as you always should do with content inside code snippets):
«««
Inline-Code: `i am inline code` Inline-Code: `i am inline code`
Inline-Code der ein Stringliteral enthält: `i am inline code "I am a string literal"` Inline-Code der ein Stringliteral enthält: `i am inline code "I am a string literal"`
Inline-Code der nur ein kurzes Stringliteral enthält: `"foo"` Inline-Code der nur ein kurzes Stringliteral enthält: `"foo"`
`"__main__"` `"__main__"`
`"fastapi[standard]"`
»»»
### Ellipsis
4) make sure there is a space between an ellipsis and a word following or preceding it. 1) Make sure there is a space between an ellipsis and a word following or preceding the ellipsis.
Examples: Examples:
Source (English): Source (English):
«««
...as we intended. ...as we intended.
...this would work: ...this would work:
...etc. ...etc.
others... others...
More to come... More to come...
»»»
Result (German): Result (German):
«««
... wie wir es beabsichtigt hatten. ... wie wir es beabsichtigt hatten.
... das würde funktionieren: ... das würde funktionieren:
... usw. ... usw.
Andere ... Andere ...
Später mehr ... Später mehr ...
»»»
4.1) Rule 4 does not apply in URLs, code blocks, inline code. Do not change the spaces there. 2) This does not apply in URLs, code blocks, and code snippets. Do not remove or add spaces there.
5) Translate HTML abbr elements as follows:
5.1) If the title attribute gives the full phrase for an abbreviation, then keep the phrase, append a long dash (`–`), followed by the translation of the phrase.
Examples:
Source (English):
<abbr title="Internet of Things">IoT</abbr>
<abbr title="Central Processing Unit">CPU</abbr>
<abbr title="too long; didn't read"><strong>TL;DR:</strong></abbr>
Result (German):
<abbr title="Internet of Things – Internet der Dinge">IoT</abbr>
<abbr title="Central Processing Unit – Zentrale Verarbeitungseinheit">CPU</abbr>
<abbr title="too long; didn't read – zu lang; hab's nicht gelesen"><strong>TL;DR:</strong></abbr>
Conversion scheme title attribute:
Source (English):
{full phrase}
Result (German):
{full phrase} – {translation of full phrase}
5.1.1) If the phrase can not be translated, or it is the same in the translation, then keep the title attribute as is.
Examples:
Source (English):
<abbr title="JSON Web Tokens">JWT</abbr>
<abbr title="Enumeration">`Enum`</abbr>
Result (German):
<abbr title="JSON Web Tokens">JWT</abbr>
<abbr title="Enumeration">`Enum`</abbr>
Conversion scheme title attribute:
Source (English):
{full phrase}
Result (German):
{full phrase}
5.1.2) If the phrase can be translated and that translation has the same starting letters, then just use the translation.
Examples:
Source (English):
<abbr title="Asynchronous Server Gateway Interface">ASGI</abbr>
Result (German):
<abbr title="Asynchrones Server-Gateway-Interface">ASGI</abbr>
Conversion scheme title attribute:
Source (English):
{full phrase}
Result (German):
{translation of full phrase} ### Headings
5.2) If the title attribute explains something in its own words, then translate it, if possible. 1) Translate headings using the infinite form.
Examples:
Source (English):
<abbr title="also known as: endpoints, routes">path</abbr>
<abbr title="A program that checks for code errors">linter</abbr>
<abbr title="converting the string that comes from an HTTP request into Python data">"parsing"</abbr>
<abbr title="before 2023-03">0.95.0</abbr>
<abbr title="2023-08-26">at the time of writing this</abbr>
Result (German):
<abbr title="auch bekannt als: Endpunkte, Routen">Pfad</abbr>
<abbr title="Programm das auf Fehler im Code prüft">Linter</abbr>
<abbr title="Konvertieren des Strings eines HTTP-Requests in Python-Daten">„Parsen“</abbr>
<abbr title="vor 2023-03">0.95.0</abbr>
<abbr title="2023-08-26">zum Zeitpunkt als das hier geschrieben wurde</abbr>
Conversion scheme title attribute:
Source (English):
{explanation}
Result (German):
{translation of explanation}
5.2.1) If the term, which the HTML abbr element wraps, stays English in the translation, but it also has a translation, whose knowledge improves the explanation, then let the title attribute be that translation, followed by a colon (`:`), followed by the translation of the title attribute.
Examples:
Source (English):
<abbr title="also known as components, resources, providers, services, injectables">Dependency Injection</abbr>
Result (German):
<abbr title="Einbringen von Abhängigkeiten: auch bekannt als Komponenten, Ressourcen, Provider, Services, Injectables">Dependency Injection</abbr>
Conversion scheme title attribute:
Source (English):
{explanation}
Result (German):
{translation of term which abbr wraps}: {translation of explanation}
5.3) If the title attribute gives the full phrase for an abbreviation, followed by a colon (`:`) or a comma (`,`), followed by an explanation, then keep the phrase, append a long dash (`–`), followed by the translation of the phrase, followed by a colon (`:`), followed by the translation of the explanation.
Examples:
Source (English):
<abbr title="Input/Output: disk reading or writing, network communication.">I/O</abbr>
<abbr title="Content Delivery Network: Service, that provides static files.">CDN</abbr>
<abbr title="Integrated Development Environment, similar to a code editor">IDE</abbr>
<abbr title="Object Relational Mapper, a fancy term for a library where some classes represent SQL tables and instances represent rows in those tables">"ORMs"</abbr>
Result (German):
<abbr title="Input/Output – Eingabe/Ausgabe: Lesen oder Schreiben auf der Festplatte, Netzwerkkommunikation.">I/O</abbr>
<abbr title="Content Delivery Network – Inhalte auslieferndes Netzwerk: Dienst, der statische Dateien bereitstellt.">CDN</abbr>
<abbr title="Integrated Development Environment – Integrierte Entwicklungsumgebung: Ähnlich einem Code-Editor">IDE</abbr>
<abbr title="Object Relational Mapper – Objektrelationaler Mapper: Ein Fachbegriff für eine Bibliothek, in der einige Klassen SQL-Tabellen und Instanzen Zeilen in diesen Tabellen darstellen">„ORMs“</abbr>
Conversion scheme title attribute:
Source (English):
{full phrase}: {explanation}
OR
Source (English):
{full phrase}, {explanation}
Result (German):
{full phrase} – {translation of full phrase}: {translation of explanation}
5.4) If there is an HTML abbr element in a sentence in an existing translation, but that element does not exist in the related sentence in the English text, then keep that HTML abbr element in the translation, do not change or remove it. Except when you remove the whole sentence from the translation, because the whole sentence was removed from the English text. The reasoning for this rule is, that such abbr elements are manually added by the human editor of the translation, in order to translate or explain an English word to the human readers of the translation. They would not make sense in the English text, but they do make sense in the translation. So keep them in the translation, even though they are not part of the English text. This rule only applies to HTML abbr elements.
6) Translate headings using the infinite form.
Examples: Examples:
Source (English): Source (English):
«««
## Create a Project { #create-a-project } ## Create a Project { #create-a-project }
»»»
Translate with (German): Translate with (German):
«««
## Ein Projekt erstellen { #create-a-project } ## Ein Projekt erstellen { #create-a-project }
»»»
Do NOT translate with (German): Do NOT translate with (German):
«««
## Erstellen Sie ein Projekt { #create-a-project } ## Erstellen Sie ein Projekt { #create-a-project }
»»»
Source (English): Source (English):
«««
# Install Packages { #install-packages } # Install Packages { #install-packages }
»»»
Translate with (German): Translate with (German):
«««
# Pakete installieren { #install-packages } # Pakete installieren { #install-packages }
»»»
Do NOT translate with (German): Do NOT translate with (German):
«««
# Installieren Sie Pakete { #install-packages } # Installieren Sie Pakete { #install-packages }
»»»
Source (English): Source (English):
«««
### Run Your Program { #run-your-program } ### Run Your Program { #run-your-program }
»»»
Translate with (German): Translate with (German):
«««
### Ihr Programm ausführen { #run-your-program } ### Ihr Programm ausführen { #run-your-program }
»»»
Do NOT translate with (German): Do NOT translate with (German):
«««
### Führen Sie Ihr Programm aus { #run-your-program } ### Führen Sie Ihr Programm aus { #run-your-program }
»»»
6.1) Make sure that the translated part of the heading does not end with a period. 2) Make sure that the translated part of the heading does not end with a period.
Example: Example:
Source (English): Source (English):
«««
## Another module with `APIRouter` { #another-module-with-apirouter } ## Another module with `APIRouter` { #another-module-with-apirouter }
»»»
Translate with (German): Translate with (German):
«««
## Ein weiteres Modul mit `APIRouter` { #another-module-with-apirouter } ## Ein weiteres Modul mit `APIRouter` { #another-module-with-apirouter }
»»»
Do NOT translate with (German) – notice the added period: Do NOT translate with (German) – notice the added period:
«««
## Ein weiteres Modul mit `APIRouter`. { #another-module-with-apirouter } ## Ein weiteres Modul mit `APIRouter`. { #another-module-with-apirouter }
»»»
6.2) Replace occurrences of literal ` - ` (a space followed by a dash followed by a space) with ` – ` (a space followed by a long dash followed by a space) in the translated part of the heading. 3) Replace occurrences of literal « - » (a space followed by a hyphen followed by a space) with « – » (a space followed by a dash followed by a space) in the translated part of the heading.
Example: Example:
Source (English): Source (English):
«««
# FastAPI in Containers - Docker { #fastapi-in-containers-docker } # FastAPI in Containers - Docker { #fastapi-in-containers-docker }
»»»
Translate with (German) – notice the long dash: Translate with (German) – notice the dash:
«««
# FastAPI in Containern – Docker { #fastapi-in-containers-docker } # FastAPI in Containern – Docker { #fastapi-in-containers-docker }
»»»
Do NOT translate with (German): Do NOT translate with (German) – notice the hyphen:
«««
# FastAPI in Containern - Docker { #fastapi-in-containers-docker } # FastAPI in Containern - Docker { #fastapi-in-containers-docker }
»»»
6.2.1) Do not apply rule 6.2 when there is no space before or after the dash. 3.1) Do not apply rule 3 when there is no space before or no space after the dash.
Example: Example:
Source (English): Source (English):
«««
## Type hints and annotations { #type-hints-and-annotations } ## Type hints and annotations { #type-hints-and-annotations }
»»»
Translate with (German) – use a short dash: Translate with (German) – use a short dash:
«««
## Typhinweise und -annotationen { #type-hints-and-annotations } ## Typhinweise und -annotationen { #type-hints-and-annotations }
»»»
Do NOT translate with (German): Do NOT translate with (German):
«««
## Typhinweise und –annotationen { #type-hints-and-annotations } ## Typhinweise und –annotationen { #type-hints-and-annotations }
»»»
Rule 6.2 does not apply to the untranslated part of the heading inside curly brackets, which you shall not translate.
3.2) Do not apply rule 3 to the untranslated part of the heading inside curly brackets, which you shall not translate.
7) Follow these German instructions:
### German instructions, when to use and when not to use hyphens in words (written in first person, which is you)
In der Regel versuche ich so weit wie möglich Worte zusammenzuschreiben, also ohne Bindestrich, es sei denn, es ist Konkretesding-Klassevondingen, etwa `Pydantic-Modell` (aber: `Datenbankmodell`), `Python-Modul` (aber: `Standardmodul`). Ich setze auch einen Bindestrich, wenn er die gleichen Buchstaben verbindet, etwa `Enum-Member`, `Cloud-Dienst`, `Template-Engine`. Oder wenn das Wort sonst einfach zu lang wird, etwa, `Performance-Optimierung`. Oder um etwas visuell besser zu dokumentieren, etwa `Pfadoperation-Dekorator`, `Pfadoperation-Funktion`.
In der Regel versuche ich so weit wie möglich Worte zusammenzuschreiben, also ohne Bindestrich, es sei denn, es ist Konkretesding-Klassevondingen, etwa «Pydantic-Modell» (aber: «Datenbankmodell»), «Python-Modul» (aber: «Standardmodul»). Ich setze auch einen Bindestrich, wenn er die gleichen Buchstaben verbindet, etwa «Enum-Member», «Cloud-Dienst», «Template-Engine». Oder wenn das Wort sonst einfach zu lang wird, etwa, «Performance-Optimierung». Oder um etwas visuell besser zu dokumentieren, etwa «Pfadoperation-Dekorator», «Pfadoperation-Funktion».
Ich versuche nicht, alles einzudeutschen. Das bezieht sich besonders auf Begriffe aus dem Bereich der Programmierung. Ich wandele zwar korrekt in Großschreibung um und setze Bindestriche, wo notwendig, aber ansonsten lasse ich solch ein Wort unverändert. Beispielsweise wird aus dem englischen Wort `string` in der deutschen Übersetzung `String`, aber nicht `Zeichenkette`. Oder aus dem englischen Wort `request body` wird in der deutschen Übersetzung `Requestbody`, aber nicht `Anfragekörper`. Oder aus dem englischen `response` wird im Deutschen `Response`, aber nicht `Antwort`.
### German instructions about difficult to translate technical terms (written in first person, which is you)
8) Below is a list of English terms and their German translations, separated by a colon (`:`). Use these translations, do not use your own. Words inside brackets are explanations for you, they are not part of the term or the translation. If a list item starts with `NOT`, then that means: do NOT use this translation. Nouns, starting with the word `the`, have their German genus – `der`, `die`, `das` – included, to help you to grammatically decline them in the translation, and they are given in singular case unless they have `(plural case)` attached, which means they are given in plural case. Verbs are given in the full infinitive – starting with the word `to`.
Ich versuche nicht, alles einzudeutschen. Das bezieht sich besonders auf Begriffe aus dem Bereich der Programmierung. Ich wandele zwar korrekt in Großschreibung um und setze Bindestriche, wo notwendig, aber ansonsten lasse ich solch ein Wort unverändert. Beispielsweise wird aus dem englischen Wort «string» in der deutschen Übersetzung «String», aber nicht «Zeichenkette». Oder aus dem englischen Wort «request body» wird in der deutschen Übersetzung «Requestbody», aber nicht «Anfragekörper». Oder aus dem englischen «response» wird im Deutschen «Response», aber nicht «Antwort».
* /// check: /// check | Testen
* /// danger: /// danger | Gefahr
* /// info: /// info | Info ### List of English terms and their preferred German translations
* /// note | Technical Details: /// note | Technische Details
* /// note: /// note | Hinweis Below is a list of English terms and their preferred German translations, separated by a colon («:»). Use these translations, do not use your own. If an existing translation does not use these terms, update it to use them. A term or a translation may be followed by an explanation in brackets, which explains when to translate the term this way. If a translation is preceded by «NOT», then that means: do NOT use this translation for this term. English nouns, starting with the word «the», have the German genus – «der», «die», «das» – prepended to their German translation, to help you to grammatically decline the translation. They are given in singular case, unless they have «(plural)» attached, which means they are given in plural case. Verbs are given in the full infinitive – starting with the word «to».
* /// tip: /// tip | Tipp
* /// warning: /// warning | Achtung * «/// check»: «/// check | Testen»
* you: Sie * «/// danger»: «/// danger | Gefahr»
* your: Ihr * «/// info»: «/// info | Info»
* e.g: z. B. * «/// note | Technical Details»: «/// note | Technische Details»
* etc.: usw. * «/// note»: «/// note | Hinweis»
* the `PATH` environment variable: die `PATH`-Umgebungsvariable * «/// tip»: «/// tip | Tipp»
* the `PATH`: der `PATH` * «/// warning»: «/// warning | Achtung»
* the `requirements.txt`: die `requirements.txt` * «you»: «Sie»
* the API Router: der API-Router * «your»: «Ihr»
* the app: die App * «e.g»: «z. B.»
* the application: die Anwendung * «etc.»: «usw.»
* the Advanced User Guide: das Handbuch für fortgeschrittene Benutzer * «the `PATH` environment variable»: «die `PATH`-Umgebungsvariable»
* the Authorization-Header: der Autorisierungsheader * «the `PATH`»: «der `PATH`»
* the `Authorization`-Header: der `Authorization`-Header * «the `requirements.txt`»: «die `requirements.txt`»
* the background task: der Hintergrundtask * «the API Router»: «der API-Router»
* the cloud provider: der Cloudanbieter * «the app»: «die App»
* the CLI: Das CLI * «the application»: «die Anwendung»
* the command line interface: Das Kommandozeileninterface * «the Advanced User Guide»: «das Handbuch für fortgeschrittene Benutzer»
* the docs: die Dokumentation (use singular case) * «the Authorization-Header»: «der Autorisierungsheader»
* the default value: der Defaultwert * «the `Authorization`-Header»: «der `Authorization`-Header»
* NOT the default value: der Standardwert * «the background task»: «der Hintergrundtask»
* the default declaration: die Default-Deklaration * «the cloud provider»: «der Cloudanbieter»
* the engine: die Engine * «the CLI»: «Das CLI»
* the env var: die Umgebungsvariable * «the command line interface»: «Das Kommandozeileninterface»
* the error response: die Error-Response * «the docs»: «die Dokumentation» (use singular case)
* the event: das Event * «the default value»: «der Defaultwert»
* the exception: die Exception * «the default value»: NOT «der Standardwert»
* the exception handler: der Exceptionhandler * «the default declaration»: «die Default-Deklaration»
* the form model: das Formularmodell * «the engine»: «die Engine»
* the form body: der Formularbody * «the env var»: «die Umgebungsvariable»
* the header: der Header * «the error response»: «die Error-Response»
* the headers (plural case): die Header * «the event»: «das Event»
* in headers (plural case): in Headern * «the exception»: «die Exception»
* the lifespan event: das Lifespan-Event * «the exception handler»: «der Exceptionhandler»
* the locking: das Locking * «the form model»: «das Formularmodell»
* the mobile application: die Mobile-Anwendung * «the form body»: «der Formularbody»
* the model object: das Modellobjekt * «the header»: «der Header»
* the mounting: das Mounten * «the headers» (plural): «die Header»
* mounted: gemountet * «in headers» (plural): «in Headern»
* the origin: das Origin * «the lifespan event»: «das Lifespan-Event»
* the override: Die Überschreibung * «the lock»: «der Lock»
* the parameter: der Parameter * «the locking»: «das Locking»
* the parameters (plural case): die Parameter * «the mobile application»: «die Mobile-Anwendung»
* the function parameter: der Funktionsparameter * «the model object»: «das Modellobjekt»
* the default parameter: der Defaultparameter * «the mounting»: «das Mounten»
* the body parameter: der Body-Parameter * «mounted»: «gemountet»
* the request body parameter: der Requestbody-Parameter * «the origin»: «das Origin»
* the path parameter: der Pfad-Parameter * «the override»: «Die Überschreibung»
* the query parameter: der Query-Parameter * «the parameter»: «der Parameter»
* the cookie parameter: der Cookie-Parameter * «the parameters» (plural): «die Parameter»
* the header parameter: der Header-Parameter * «the function parameter»: «der Funktionsparameter»
* the form parameter: der Formular-Parameter * «the default parameter»: «der Defaultparameter»
* the payload: die Payload * «the body parameter»: «der Body-Parameter»
* the query: die Query * «the request body parameter»: «der Requestbody-Parameter»
* the recap: die Zusammenfassung * «the path parameter»: «der Pfad-Parameter»
* the request: der Request * «the query parameter»: «der Query-Parameter»
* the requestbody: der Requestbody * «the cookie parameter»: «der Cookie-Parameter»
* the requestbodies (plural case): die Requestbodys * «the header parameter»: «der Header-Parameter»
* the response: die Response * «the form parameter»: «der Formular-Parameter»
* the return type: der Rückgabetyp * «the payload»: «die Payload»
* the return value: der Rückgabewert * «the query»: «die Query»
* the SQLModel docs: die SQLModel-Dokumentation * «the recap»: «die Zusammenfassung»
* the SDK: das SDK * «the request»: «der Request»
* the tag: der Tag * «the request body»: «der Requestbody»
* the Tutorial - User guide: das Tutorial – Benutzerhandbuch * «the request bodies» (plural): «die Requestbodys»
* the type annotation: die Typannotation * «the response»: «die Response»
* the type hint: der Typhinweis * «the return type»: «der Rückgabetyp»
* the wildcard: die Wildcard * «the return value»: «der Rückgabewert»
* the worker class: die Workerklasse * «the SQLModel docs»: «die SQLModel-Dokumentation»
* NOT the worker class: die Arbeiterklasse * «the SDK»: «das SDK»
* the worker process: der Workerprozess * «the tag»: «der Tag»
* NOT the worker process: der Arbeiterprozess * «the Tutorial - User guide»: «das Tutorial – Benutzerhandbuch»
* to commit: committen * «the type annotation»: «die Typannotation»
* to modify: ändern * «the type hint»: «der Typhinweis»
* to serve (an application): bereitstellen * «the wildcard»: «die Wildcard»
* to serve (a response): ausliefern * «the worker class»: «die Workerklasse»
* NOT to serve: bedienen * «the worker class»: NOT «die Arbeiterklasse»
* to upgrade: aktualisieren * «the worker process»: «der Workerprozess»
* to wrap: wrappen * «the worker process»: NOT «der Arbeiterprozess»
* `foo` as a `type`: `foo` vom Typ `type` * «to commit»: «committen»
* `foo` as a `type`: `foo`, ein `type` * «to modify»: «ändern»
* FastAPI's X: FastAPIs X * «to serve» (an application): «bereitstellen»
* Starlette's Y: Starlettes Y * «to serve» (a response): «ausliefern»
* X is case-sensitive: Groß-/Klein­schrei­bung ist relevant in X * «to serve»: NOT «bedienen»
* X is case-insensitive: Groß-/Klein­schrei­bung ist nicht relevant in X * «to upgrade»: «aktualisieren»
* standard Python: Standard-Python * «to wrap»: «wrappen»
* deprecated: deprecatet * «`foo` as a `type`»: «`foo` vom Typ `type`»
* «`foo` as a `type`»: «`foo`, ein `type`»
* «FastAPI's X»: «FastAPIs X»
9) Preserve indentation. Keep emoticons. Encode in utf-8. Use Linux line breaks (LF) * «Starlette's Y»: «Starlettes Y»
* «X is case-sensitive»: «Groß-/Klein­schrei­bung ist relevant in X»
* «X is case-insensitive»: «Groß-/Klein­schrei­bung ist nicht relevant in X»
* «standard Python»: «Standard-Python»
* «deprecated»: «deprecatet»
### Other rules
Preserve indentation. Keep emoticons. Encode in utf-8. Use Linux line breaks (LF)

343
scripts/translate.py

@ -24,51 +24,143 @@ non_translated_sections = (
"contributing.md", "contributing.md",
) )
general_prompt = """ general_prompt = """
### About literal text in this prompt
1) In the following instructions (after I say: `The above rules are in effect now`) the two characters `«` and `»` will be used to surround text and characters which you shall interpret literally. The `«` and the `»` are not part of the literal text (they are the meta characters denoting it).
2) Furthermore, text surrounded by `«««` and `»»»` is a block of literal text which spans multiple lines. To get its content, dedent all lines of the block until the `«««` and `»»»` are at column zero, then remove the newline after the `«««` and the newline before the `»»»`. The `«««` and the `»»»` are not part of the literal text block (they are the meta characters denoting it).
3) The above two syntaxes `«...»` and `«««...»»»` are used to denote literal text. Other forms of quotation marks especially backticks and triple backticks do NOT denote literal text.
The above rules are relevant, because we will give code examples for Markdown. Markdown uses backticks to denote inline code and code blocks. So, if you see text surrounded by backticks, then do not interpret it as literal text and throw away the backticks, but interpret it as a Markdown code block or a Markdown code snippet, and keep the backticks.
The above rules are in effect now.
### Definitions of terms used in this prompt
Backtick
The character «`»
Unicode U+0060 (GRAVE ACCENT)
Single backtick
A single backtick «`»
triple backticks
Three backticks in a row «```»
Neutral double quote
The character «"»
Unicode U+0022 (QUOTATION MARK)
Neutral single quote
The character «'»
Unicode U+0027 (APOSTROPHE)
English double typographic quotes
The characters «» and «»
Unicode U+201C (LEFT DOUBLE QUOTATION MARK) and Unicode U+201D (RIGHT DOUBLE QUOTATION MARK)
English single typographic quotes
The characters «» and «»
Unicode U+2018 (LEFT SINGLE QUOTATION MARK) and Unicode U+2019 (RIGHT SINGLE QUOTATION MARK)
Code snippet
Text in a Markdown document which is surrounded by single backticks.
Examples:
«`foo`»
«`lorem ipsum`»
Code block
Text in a Markdown document which is surrounded by triple backticks. Spreads multiple lines.
Example:
«««
```
Hello
World
```
»»»
Example:
«««
```python
print("hello World")
```
»»»
### Your task
Translate an English text the original content to a target language.
The original content is written in Markdown, write the translation in Markdown as well.
The original content will be surrounded by triple percentage signs («%%%»). Do not include the triple percentage signs in the translation.
### Technical terms in English
For technical terms in English that don't have a common translation term, use the original term in English. For technical terms in English that don't have a common translation term, use the original term in English.
For code snippets or fragments, surrounded by backticks (`), don't translate the content, keep the original in English. For example, `list`, `dict`, keep them as is.
The content is written in Markdown, write the translation in Markdown as well. ### Content of code snippets
Do not translate the content of code snippets, keep the original in English. For example, «`list`», «`dict`», keep them as is.
When there is a code block, surrounded by triple backticks, do not translate its content, except for comments in the language which the code block uses. ### Content of code blocks
Do not translate the content of code blocks, except for comments in the language which the code block uses.
Examples: Examples:
Source (English) The code block is a bash code example with one comment: Source (English) The code block is a bash code example with one comment:
«««
```bash ```bash
# Print greeting # Print greeting
echo "Hello, World!" echo "Hello, World!"
``` ```
»»»
Result (German): Result (German):
«««
```bash ```bash
# Gruß ausgeben # Gruß ausgeben
echo "Hello, World!" echo "Hello, World!"
``` ```
»»»
Source (English) The code block is a console example containing HTML tags. No comments, nothing to change here: Source (English) The code block is a console example containing HTML tags. No comments, so nothing to change here:
«««
```console ```console
$ <font color="#4E9A06">fastapi</font> run <u style="text-decoration-style:solid">main.py</u> $ <font color="#4E9A06">fastapi</font> run <u style="text-decoration-style:solid">main.py</u>
<span style="background-color:#009485"><font color="#D3D7CF"> FastAPI </font></span> Starting server <span style="background-color:#009485"><font color="#D3D7CF"> FastAPI </font></span> Starting server
Searching for package file structure Searching for package file structure
``` ```
»»»
Result (German): Result (German):
«««
```console ```console
$ <font color="#4E9A06">fastapi</font> run <u style="text-decoration-style:solid">main.py</u> $ <font color="#4E9A06">fastapi</font> run <u style="text-decoration-style:solid">main.py</u>
<span style="background-color:#009485"><font color="#D3D7CF"> FastAPI </font></span> Starting server <span style="background-color:#009485"><font color="#D3D7CF"> FastAPI </font></span> Starting server
Searching for package file structure Searching for package file structure
``` ```
»»»
Source (English) The code block is a console example containing 5 comments: Source (English) The code block is a console example containing 5 comments:
«««
```console ```console
// Go to the home directory // Go to the home directory
$ cd $ cd
@ -81,9 +173,11 @@ $ mkdir awesome-project
// Enter into that project directory // Enter into that project directory
$ cd awesome-project $ cd awesome-project
``` ```
»»»
Result (German): Result (German):
«««
```console ```console
// Gehe zum Home-Verzeichnis // Gehe zum Home-Verzeichnis
$ cd $ cd
@ -96,6 +190,7 @@ $ mkdir awesome-project
// Gehe in dieses Projektverzeichnis // Gehe in dieses Projektverzeichnis
$ cd awesome-project $ cd awesome-project
``` ```
»»»
If there is an existing translation and its Mermaid diagram is in sync with the Mermaid diagram in the English source, except a few translated words, then use the Mermaid diagram of the existing translation. The human editor of the translation translated these words in the Mermaid diagram. Keep these translations, do not revert them back to the English source. If there is an existing translation and its Mermaid diagram is in sync with the Mermaid diagram in the English source, except a few translated words, then use the Mermaid diagram of the existing translation. The human editor of the translation translated these words in the Mermaid diagram. Keep these translations, do not revert them back to the English source.
@ -103,6 +198,7 @@ Example:
Source (English): Source (English):
«««
```mermaid ```mermaid
flowchart LR flowchart LR
subgraph global[global env] subgraph global[global env]
@ -112,9 +208,11 @@ flowchart LR
stone(philosophers-stone) -->|requires| harry-1 stone(philosophers-stone) -->|requires| harry-1
end end
``` ```
»»»
Existing translation (German) has three translations: Existing translation (German) has three translations:
«««
```mermaid ```mermaid
flowchart LR flowchart LR
subgraph global[globale Umgebung] subgraph global[globale Umgebung]
@ -124,9 +222,11 @@ flowchart LR
stone(philosophers-stone) -->|benötigt| harry-1 stone(philosophers-stone) -->|benötigt| harry-1
end end
``` ```
»»»
Result (German) you change nothing: Result (German) you change nothing:
«««
```mermaid ```mermaid
flowchart LR flowchart LR
subgraph global[globale Umgebung] subgraph global[globale Umgebung]
@ -136,74 +236,100 @@ flowchart LR
stone(philosophers-stone) -->|benötigt| harry-1 stone(philosophers-stone) -->|benötigt| harry-1
end end
``` ```
»»»
The original content will be surrounded by triple percentage signs (%) and you should translate it to the target language. Do not include the triple percentage signs in the translation. ### Special blocks
There are special blocks of notes, tips and others that look like: There are special blocks of notes, tips and others that look like:
«««
/// note /// note
»»»
To translate it, keep the same line and add the translation after a vertical bar. To translate it, keep the same line and add the translation after a vertical bar.
For example, if you were translating to Spanish, you would write: For example, if you were translating to Spanish, you would write:
«««
/// note | Nota /// note | Nota
»»»
Some examples in Spanish: Some examples in Spanish:
Source: Source:
«««
/// tip /// tip
»»»
Result: Result:
«««
/// tip | Consejo /// tip | Consejo
»»»
Source: Source:
«««
/// details | Preview /// details | Preview
»»»
Result: Result:
«««
/// details | Vista previa /// details | Vista previa
»»»
There are special blocks surrounded by four slashes (`////`). They mark text, which will be rendered as part of a tab in the final document. The scheme is: ### Tab blocks
There are special blocks surrounded by four slashes («////»). They mark text, which will be rendered as part of a tab in the final document. The scheme is:
«««
//// tab | {tab title} //// tab | {tab title}
{tab content, may span many lines} {tab content, may span many lines}
//// ////
»»»
Keep everything before the vertical bar (`|`) as is, including the vertical bar. Translate the tab title. Translate the tab content, applying the rules you know. Keep the four block closing slashes as is. Keep everything before the vertical bar («|») as is, including the vertical bar. Translate the tab title. Translate the tab content, applying the rules you know. Keep the four block closing slashes as is.
Examples: Examples:
Source (English): Source (English):
«««
//// tab | Python 3.8+ non-Annotated //// tab | Python 3.8+ non-Annotated
Hello Hello
//// ////
»»»
Result (German): Result (German):
«««
//// tab | Python 3.8+ nicht annotiert //// tab | Python 3.8+ nicht annotiert
Hallo Hallo
//// ////
»»»
Source (English) Here there is nothing to translate in the tab title: Source (English) Here there is nothing to translate in the tab title:
«««
//// tab | Linux, macOS, Windows Bash //// tab | Linux, macOS, Windows Bash
Hello again Hello again
//// ////
»»»
Result (German): Result (German):
«««
//// tab | Linux, macOS, Windows Bash //// tab | Linux, macOS, Windows Bash
Hallo wieder Hallo wieder
//// ////
»»»
### Headings
Every Markdown heading in the English text (all levels) ends with a part inside curly brackets. This part denotes the hash of this heading, which is used in links to this heading. In translations, translate the heading, but do not translate this hash part, so that links do not break. Every Markdown heading in the English text (all levels) ends with a part inside curly brackets. This part denotes the hash of this heading, which is used in links to this heading. In translations, translate the heading, but do not translate this hash part, so that links do not break.
@ -211,58 +337,80 @@ Examples of how to translate a heading:
Source (English): Source (English):
«««
## Alternative API docs { #alternative-api-docs } ## Alternative API docs { #alternative-api-docs }
»»»
Result (Spanish): Result (Spanish):
«««
## Documentación de la API alternativa { #alternative-api-docs } ## Documentación de la API alternativa { #alternative-api-docs }
»»»
Source (English): Source (English):
«««
### Example { #example } ### Example { #example }
»»»
Result (German): Result (German):
«««
### Beispiel { #example } ### Beispiel { #example }
»»»
Use the following rules for links (apply both to Markdown-style links ([text](url)) and to HTML-style <a> tags): ### Links
1) For relative URLs only translate link text. Do not translate the URL or its parts Use the following rules for links (apply both to Markdown-style links («[text](url)») and to HTML-style «<a>» tags):
1) For relative URLs, only translate link text. Do not translate the URL or its parts
Example: Example:
Source (English): Source (English):
«««
[One of the fastest Python frameworks available](#performance) [One of the fastest Python frameworks available](#performance)
»»»
Result (German): Result (German):
«««
[Eines der schnellsten verfügbaren Python-Frameworks](#performance) [Eines der schnellsten verfügbaren Python-Frameworks](#performance)
»»»
2) For absolute URLs which DO NOT start EXACTLY with "https://fastapi.tiangolo.com", only translate link text and leave the URL unchanged. 2) For absolute URLs which DO NOT start EXACTLY with «https://fastapi.tiangolo.com», only translate link text and leave the URL unchanged.
Example: Example:
Source (English): Source (English):
«««
<a href="https://sqlmodel.tiangolo.com/" class="external-link" target="_blank">SQLModel docs</a> <a href="https://sqlmodel.tiangolo.com/" class="external-link" target="_blank">SQLModel docs</a>
»»»
Result (German): Result (German):
«««
<a href="https://sqlmodel.tiangolo.com/" class="external-link" target="_blank">SQLModel-Dokumentation</a> <a href="https://sqlmodel.tiangolo.com/" class="external-link" target="_blank">SQLModel-Dokumentation</a>
»»»
3) For absolute URLs which DO start EXACTLY with "https://fastapi.tiangolo.com", only translate link text and change the URL by adding language code (https://fastapi.tiangolo.com/{language_code}[rest part of the url]). 3) For absolute URLs which DO start EXACTLY with «https://fastapi.tiangolo.com», only translate link text and change the URL by adding language code («https://fastapi.tiangolo.com/{language_code}[rest part of the url]»).
Example: Example:
Source (English): Source (English):
«««
<a href="https://fastapi.tiangolo.com/tutorial/path-params/#documentation" class="external-link" target="_blank">Documentation</a> <a href="https://fastapi.tiangolo.com/tutorial/path-params/#documentation" class="external-link" target="_blank">Documentation</a>
»»»
Result (Spanish): Result (Spanish):
«««
<a href="https://fastapi.tiangolo.com/es/tutorial/path-params/#documentation" class="external-link" target="_blank">Documentación</a> <a href="https://fastapi.tiangolo.com/es/tutorial/path-params/#documentation" class="external-link" target="_blank">Documentación</a>
»»»
3.1) Do not add language codes for URLs that point to static assets (e.g., images, CSS, JavaScript). 3.1) Do not add language codes for URLs that point to static assets (e.g., images, CSS, JavaScript).
@ -270,11 +418,15 @@ Example:
Source (English): Source (English):
«««
<a href="https://fastapi.tiangolo.com/img/something.jpg" class="external-link" target="_blank">Something</a> <a href="https://fastapi.tiangolo.com/img/something.jpg" class="external-link" target="_blank">Something</a>
»»»
Result (Spanish): Result (Spanish):
«««
<a href="https://fastapi.tiangolo.com/img/something.jpg" class="external-link" target="_blank">Algo</a> <a href="https://fastapi.tiangolo.com/img/something.jpg" class="external-link" target="_blank">Algo</a>
»»»
4) For internal links, only translate link text. 4) For internal links, only translate link text.
@ -282,13 +434,17 @@ Example:
Source (English): Source (English):
«««
[Create Pull Requests](help-fastapi.md#create-a-pull-request){.internal-link target=_blank} [Create Pull Requests](help-fastapi.md#create-a-pull-request){.internal-link target=_blank}
»»»
Result (German): Result (German):
«««
[Pull Requests erzeugen](help-fastapi.md#create-a-pull-request){.internal-link target=_blank} [Pull Requests erzeugen](help-fastapi.md#create-a-pull-request){.internal-link target=_blank}
»»»
5) Do not translate anchor fragments in links (the part after #), as they must remain the same to work correctly. 5) Do not translate anchor fragments in links (the part after «#»), as they must remain the same to work correctly.
5.1) If an existing translation has a link with an anchor fragment different to the anchor fragment in the English source, then this is an error. Fix this by using the anchor fragment of the English source. 5.1) If an existing translation has a link with an anchor fragment different to the anchor fragment in the English source, then this is an error. Fix this by using the anchor fragment of the English source.
@ -296,15 +452,21 @@ Example:
Source (English): Source (English):
«««
[Body - Multiple Parameters: Singular values in body](body-multiple-params.md#singular-values-in-body){.internal-link target=_blank} [Body - Multiple Parameters: Singular values in body](body-multiple-params.md#singular-values-in-body){.internal-link target=_blank}
»»»
Existing wrong translation (German) notice the wrongly translated anchor fragment: Existing wrong translation (German) notice the wrongly translated anchor fragment:
«««
[Body Mehrere Parameter: Einfache Werte im Body](body-multiple-params.md#einzelne-werte-im-body){.internal-link target=_blank}. [Body Mehrere Parameter: Einfache Werte im Body](body-multiple-params.md#einzelne-werte-im-body){.internal-link target=_blank}.
»»»
Result (German) you fix the anchor fragment: Result (German) you fix the anchor fragment:
«««
[Body Mehrere Parameter: Einfache Werte im Body](body-multiple-params.md#singular-values-in-body){.internal-link target=_blank}. [Body Mehrere Parameter: Einfache Werte im Body](body-multiple-params.md#singular-values-in-body){.internal-link target=_blank}.
»»»
5.2) Do not add anchor fragments at will, even if this makes sense. If the English source has no anchor, don't add one. 5.2) Do not add anchor fragments at will, even if this makes sense. If the English source has no anchor, don't add one.
@ -312,15 +474,168 @@ Example:
Source (English): Source (English):
«««
Create a [virtual environment](../virtual-environments.md){.internal-link target=_blank} Create a [virtual environment](../virtual-environments.md){.internal-link target=_blank}
»»»
Wrong translation (German) Anchor added to the URL. Wrong translation (German) Anchor added to the URL.
«««
Erstelle eine [virtuelle Umgebung](../virtual-environments.md#create-a-virtual-environment){.internal-link target=_blank} Erstelle eine [virtuelle Umgebung](../virtual-environments.md#create-a-virtual-environment){.internal-link target=_blank}
»»»
Good translation (German) URL stays like in the English source. Good translation (German) URL stays like in the English source.
«««
Erstelle eine [Virtuelle Umgebung](../virtual-environments.md){.internal-link target=_blank} Erstelle eine [Virtuelle Umgebung](../virtual-environments.md){.internal-link target=_blank}
»»»
### Abbr elements
Translate HTML abbr elements as follows:
1) If the title attribute gives the full phrase for an abbreviation, then keep the phrase, append a dash («»), followed by the translation of the phrase.
Examples:
Source (English):
«««
<abbr title="Internet of Things">IoT</abbr>
<abbr title="Central Processing Unit">CPU</abbr>
<abbr title="too long; didn't read"><strong>TL;DR:</strong></abbr>
»»»
Result (German):
«««
<abbr title="Internet of Things – Internet der Dinge">IoT</abbr>
<abbr title="Central Processing Unit – Zentrale Verarbeitungseinheit">CPU</abbr>
<abbr title="too long; didn't read – zu lang; hab's nicht gelesen"><strong>TL;DR:</strong></abbr>
»»»
Conversion scheme title attribute:
Source (English):
{full phrase}
Result (German):
{full phrase} {translation of full phrase}
1.1) If the translation of the phrase starts with the same letters, then just use the translation.
Examples:
Source (English):
«««
<abbr title="JSON Web Tokens">JWT</abbr>
<abbr title="Enumeration">`Enum`</abbr>
<abbr title="Asynchronous Server Gateway Interface">ASGI</abbr>
»»»
Result (German):
«««
<abbr title="JSON Web Tokens">JWT</abbr>
<abbr title="Enumeration">`Enum`</abbr>
<abbr title="Asynchrones Server-Gateway-Interface">ASGI</abbr>
»»»
Conversion scheme title attribute:
Source (English):
{full phrase}
Result (German):
{translation of full phrase}
2) If the title attribute explains something in its own words, then translate it, if possible.
Examples:
Source (English):
«««
<abbr title="also known as: endpoints, routes">path</abbr>
<abbr title="A program that checks for code errors">linter</abbr>
<abbr title="converting the string that comes from an HTTP request into Python data">"parsing"</abbr>
<abbr title="before 2023-03">0.95.0</abbr>
<abbr title="2023-08-26">at the time of writing this</abbr>
»»»
Result (German):
«««
<abbr title="auch bekannt als: Endpunkte, Routen">Pfad</abbr>
<abbr title="Programm das auf Fehler im Code prüft">Linter</abbr>
<abbr title="Konvertieren des Strings eines HTTP-Requests in Python-Daten">Parsen</abbr>
<abbr title="vor 2023-03">0.95.0</abbr>
<abbr title="2023-08-26">zum Zeitpunkt als das hier geschrieben wurde</abbr>
»»»
Conversion scheme title attribute:
Source (English):
{explanation}
Result (German):
{translation of explanation}
3) If the title attribute gives the full phrase for an abbreviation, followed by a colon («:») or a comma («,»), followed by an explanation, then keep the phrase, append a dash («»), followed by the translation of the phrase, followed by a colon («:»), followed by the translation of the explanation.
Examples:
Source (English):
«««
<abbr title="Input/Output: disk reading or writing, network communication.">I/O</abbr>
<abbr title="Content Delivery Network: Service, that provides static files.">CDN</abbr>
<abbr title="Integrated Development Environment, similar to a code editor">IDE</abbr>
<abbr title="Object Relational Mapper, a fancy term for a library where some classes represent SQL tables and instances represent rows in those tables">"ORMs"</abbr>
»»»
Result (German):
«««
<abbr title="Input/Output – Eingabe/Ausgabe: Lesen oder Schreiben auf der Festplatte, Netzwerkkommunikation.">I/O</abbr>
<abbr title="Content Delivery Network – Inhalte auslieferndes Netzwerk: Dienst, der statische Dateien bereitstellt.">CDN</abbr>
<abbr title="Integrated Development Environment – Integrierte Entwicklungsumgebung: Ähnlich einem Code-Editor">IDE</abbr>
<abbr title="Object Relational Mapper – Objektrelationaler Mapper: Ein Fachbegriff für eine Bibliothek, in der einige Klassen SQL-Tabellen und Instanzen Zeilen in diesen Tabellen darstellen">ORMs</abbr>
»»»
Conversion scheme title attribute:
Source (English):
{full phrase}: {explanation}
OR
Source (English):
{full phrase}, {explanation}
Result (German):
{full phrase} {translation of full phrase}: {translation of explanation}
3.1) For the full phrase (the part before the dash in the translation) rule 1.1 also applies, speak, you can leave the original full phrase away and just use the translated full phrase, if it starts with the same letters. The result becomes:
Conversion scheme title attribute:
Result (German):
{translation of full phrase}: {translation of explanation}
4) If there is an HTML abbr element in a sentence in an existing translation, but that element does not exist in the related sentence in the English text, then keep that HTML abbr element in the translation, do not change or remove it. Except when you remove the whole sentence from the translation, because the whole sentence was removed from the English text. The reasoning for this rule is, that such abbr elements are manually added by the human editor of the translation, in order to translate or explain an English word to the human readers of the translation. They would not make sense in the English text, but they do make sense in the translation. So keep them in the translation, even though they are not part of the English text. This rule only applies to HTML abbr elements.
""" """

Loading…
Cancel
Save