Skip to content

Commit 5ae469c

Browse files
authored
Merge pull request #63 from PyCampES/memory-translation
Memory translation
2 parents e244025 + a67ca1f commit 5ae469c

File tree

2 files changed

+85
-0
lines changed

2 files changed

+85
-0
lines changed

.overrides/translation-memory.rst

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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:: text
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 ``docstrings``. │
26+
├────────────────────────────────────────────────────────────────────────────────────────────────┼───────────────────────────────────────────────────────────────────────────────────────────────┤
27+
28+
29+
Éstos son las palabras que hemos coordinado hasta el momento:
30+
31+
32+
loop
33+
Bucle. ``tutorial/controlflow.po``
34+
35+
handle exception
36+
Gestionar excepción. ``tutorial/inputoutput.po``
37+
38+
docstring
39+
docstring. ``library/idle.po``

scripts/find_in_po.py

+46
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)