From 919bd5122c27fd0d7c530470419826cc9f5b25eb Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Tue, 5 May 2020 12:08:11 +0200 Subject: [PATCH 1/3] Memory translation --- .overrides/translation-memory.rst | 36 ++++++++++++++++++++++++ scripts/find_in_po.py | 46 +++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 .overrides/translation-memory.rst create mode 100644 scripts/find_in_po.py diff --git a/.overrides/translation-memory.rst b/.overrides/translation-memory.rst new file mode 100644 index 0000000000..f2a9a486c0 --- /dev/null +++ b/.overrides/translation-memory.rst @@ -0,0 +1,36 @@ +======================= + Memoria de traducción +======================= + + +Esta página contiene la Memoria de Traducción, con todos los términos que hemos ido teniendo dudas, +y coordinamos cuál era la mejor traducción dado el contexto. + +Si quieres ver cómo se ha utilizado un término anteriormente, puedes utilizar la herramienta +``find_in_po.py`` que muestra dónde se usó ese término: original y traducción lado a lado: + +.. code-block:: bash + + $ python scripts/find_in_po.py docstring + ╒════════════════════════════════════════════════════════════════════════════════════════════════╤═══════════════════════════════════════════════════════════════════════════════════════════════╕ + │ 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 │ + │ 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`. │ + │ 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 │ + │ 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 │ + │ 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 │ + │ of it. │ buena práctica incluir ``docstrings`` en el código que escribes, y hacerlo un buen hábito. │ + ├────────────────────────────────────────────────────────────────────────────────────────────────┼───────────────────────────────────────────────────────────────────────────────────────────────┤ + │ Here is an example of a multi-line docstring:: │ Este es un ejemplo de un ``docstring`` multi-línea:: │ + ├────────────────────────────────────────────────────────────────────────────────────────────────┼───────────────────────────────────────────────────────────────────────────────────────────────┤ + │ Use docstrings. │ Usar ``docstrings``. │ + ├────────────────────────────────────────────────────────────────────────────────────────────────┼───────────────────────────────────────────────────────────────────────────────────────────────┤ + + +:loop: + Bucle. ``tutorial/controlflow.po`` + +:handle exception: + Gestionar excepción. ``tutorial/inputoutput.po`` + +:docstring: + docstring. ``library/idle.po`` diff --git a/scripts/find_in_po.py b/scripts/find_in_po.py new file mode 100644 index 0000000000..d38d306cef --- /dev/null +++ b/scripts/find_in_po.py @@ -0,0 +1,46 @@ +#!/usr/bin/env python3 + +import argparse +from glob import glob +import os +from textwrap import fill + +import regex +import polib +from tabulate import tabulate + + +def find_in_po(pattern): + table = [] + try: + _, columns = os.popen("stty size", "r").read().split() + available_width = int(columns) // 2 - 3 + except: + available_width = 80 // 2 - 3 + + for file in glob("**/*.po"): + pofile = polib.pofile(file) + for entry in pofile: + if entry.msgstr and regex.search(pattern, entry.msgid): + table.append( + [ + fill(entry.msgid, width=available_width), + fill(entry.msgstr, width=available_width), + ] + ) + print(tabulate(table, tablefmt="fancy_grid")) + + +def parse_args(): + parser = argparse.ArgumentParser(description="Find translated words.") + parser.add_argument("pattern") + return parser.parse_args() + + +def main(): + args = parse_args() + find_in_po(args.pattern) + + +if __name__ == "__main__": + main() From f0ec8b577f98cd9dbf865e87413b2e042d0c5fe9 Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Tue, 5 May 2020 12:20:45 +0200 Subject: [PATCH 2/3] Change pygments --- .overrides/translation-memory.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.overrides/translation-memory.rst b/.overrides/translation-memory.rst index f2a9a486c0..baed0c265d 100644 --- a/.overrides/translation-memory.rst +++ b/.overrides/translation-memory.rst @@ -9,7 +9,7 @@ y coordinamos cuál era la mejor traducción dado el contexto. Si quieres ver cómo se ha utilizado un término anteriormente, puedes utilizar la herramienta ``find_in_po.py`` que muestra dónde se usó ese término: original y traducción lado a lado: -.. code-block:: bash +.. code-block:: text $ python scripts/find_in_po.py docstring ╒════════════════════════════════════════════════════════════════════════════════════════════════╤═══════════════════════════════════════════════════════════════════════════════════════════════╕ From a67ca1ffbcc61b94b939c913470f35eb77b4d823 Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Tue, 5 May 2020 12:22:25 +0200 Subject: [PATCH 3/3] Use a definition list like in the glossary --- .overrides/translation-memory.rst | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/.overrides/translation-memory.rst b/.overrides/translation-memory.rst index baed0c265d..b8bff55117 100644 --- a/.overrides/translation-memory.rst +++ b/.overrides/translation-memory.rst @@ -26,11 +26,14 @@ Si quieres ver cómo se ha utilizado un término anteriormente, puedes utilizar ├────────────────────────────────────────────────────────────────────────────────────────────────┼───────────────────────────────────────────────────────────────────────────────────────────────┤ -:loop: - Bucle. ``tutorial/controlflow.po`` +Éstos son las palabras que hemos coordinado hasta el momento: -:handle exception: - Gestionar excepción. ``tutorial/inputoutput.po`` -:docstring: - docstring. ``library/idle.po`` + loop + Bucle. ``tutorial/controlflow.po`` + + handle exception + Gestionar excepción. ``tutorial/inputoutput.po`` + + docstring + docstring. ``library/idle.po``