8000 Memory translation · r3v1/python-docs-es@919bd51 · GitHub
[go: up one dir, main page]

Skip to content

Commit 919bd51

Browse files
committed
Memory translation
1 parent d206dcd commit 919bd51

File tree

2 files changed

+82
-0
lines changed

2 files changed

+82
-0
lines changed

.overrides/translation-memory.rst

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
=======================
2+
Memoria de traducción
3+
=======================
4+
5+
6+
Esta página contiene la Memoria de Traducción, con todos los términos que hemos ido teniendo dudas,
7+
y coordinamos cuál era la mejor traducción dado el contexto.
8+
9+
Si quieres ver cómo se ha utilizado un término anteriormente, puedes utilizar la herramienta
10+
``find_in_po.py`` que muestra dónde se usó ese término: original y traducción lado a lado:
11+
12+
.. code-block:: bash
13+
14+
$ python scripts/find_in_po.py docstring
15+
╒════════════════════════════════════════════════════════════════════════════════════════════════╤═══════════════════════════════════════════════════════════════════════════════════════════════╕
16+
│ The first statement of the function body can optionally be a string literal; this string │ La primera sentencia del cuerpo de la función puede ser opcionalmente una cadena de texto │
17+
│ literal is the function's documentation string, or :dfn:`docstring`. (More about docstrings │ literal; esta es la cadena de texto de documentación de la función, o :dfn:`docstring`. │
18+
│ can be found in the section :ref:`tut-docstrings`.) There are tools which use docstrings to │ (Puedes encontrar más acerca de docstrings en la sección :ref:`tut-docstrings`.). Existen │
19+
│ automatically produce online or printed documentation, or to let the user interactively browse │ herramientas que usan las ``docstrings`` para producir documentación imprimible o disponible │
20+
│ through code; it's good practice to include docstrings in code that you write, so make a habit │ en línea, o para dejar que los usuarios busquen interactivamente a través del código; es una │
21+
│ of it. │ buena práctica incluir ``docstrings`` en el código que escribes, y hacerlo un buen hábito. │
22+
├────────────────────────────────────────────────────────────────────────────────────────────────┼───────────────────────────────────────────────────────────────────────────────────────────────┤
23+
│ Here is an example of a multi-line docstring:: │ Este es un ejemplo de un ``docstring`` multi-línea:: │
24+
├────────────────────────────────────────────────────────────────────────────────────────────────┼───────────────────────────────────────────────────────────────────────────────────────────────┤
25+
│ Use docstrings. │ Usar < 8000 span class="pl-s">``docstrings``. │
26+
├────────────────────────────────────────────────────────────────────────────────────────────────┼───────────────────────────────────────────────────────────────────────────────────────────────┤
27+
28+
29+
:loop:
30+
Bucle. ``tutorial/controlflow.po``
31+
32+
:handle exception:
33+
Gestionar excepción. ``tutorial/inputoutput.po``
34+
35+
:docstring:
36+
docstring. ``library/idle.po``

scripts/find_in_po.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/usr/bin/env python3
2+
3+
import argparse
4+
from glob import glob
5+
import os
6+
from textwrap import fill
7+
8+
import regex
9+
import polib
10+
from tabulate import tabulate
11+
12+
13+
def find_in_po(pattern):
14+
table = []
15+
try:
16+
_, columns = os.popen("stty size", "r").read().split()
17+
available_width = int(columns) // 2 - 3
18+
except:
19+
available_width = 80 // 2 - 3
20+
21+
for file in glob("**/*.po"):
22+
pofile = polib.pofile(file)
23+
for entry in pofile:
24+
if entry.msgstr and regex.search(pattern, entry.msgid):
25+
table.append(
26+
[
27+
fill(entry.msgid, width=available_width),
28+
fill(entry.msgstr, width=available_width),
29+
]
30+
)
31+
print(tabulate(table, tablefmt="fancy_grid"))
32+
33+
34+
def parse_args():
35+
parser = argparse.ArgumentParser(description="Find translated words.")
36+
parser.add_argument("pattern")
37+
return parser.parse_args()
38+
39+
40+
def main():
41+
args = parse_args()
42+
find_in_po(args.pattern)
43+
44+
45+
if __name__ == "__main__":
46+
main()

0 commit comments

Comments
 (0)
0