Merge pull request #37185 from akien-mga/i18n-classref-headers
i18n: Improve classref translation extractor, add Makefile and generate .pot file
This commit is contained in:
commit
075870bc0d
|
@ -52,6 +52,12 @@
|
|||
Returns the editor [Viewport].
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_file_system_dock">
|
||||
<return type="FileSystemDock">
|
||||
</return>
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_inspector" qualifiers="const">
|
||||
<return type="EditorInspector">
|
||||
</return>
|
||||
|
|
|
@ -0,0 +1,101 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="FileSystemDock" inherits="VBoxContainer" version="4.0">
|
||||
<brief_description>
|
||||
</brief_description>
|
||||
<description>
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
<method name="can_drop_data_fw" qualifiers="const">
|
||||
<return type="bool">
|
||||
</return>
|
||||
<argument index="0" name="arg0" type="Vector2">
|
||||
</argument>
|
||||
<argument index="1" name="arg1" type="Variant">
|
||||
</argument>
|
||||
<argument index="2" name="arg2" type="Control">
|
||||
</argument>
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="drop_data_fw">
|
||||
<return type="void">
|
||||
</return>
|
||||
<argument index="0" name="arg0" type="Vector2">
|
||||
</argument>
|
||||
<argument index="1" name="arg1" type="Variant">
|
||||
</argument>
|
||||
<argument index="2" name="arg2" type="Control">
|
||||
</argument>
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_drag_data_fw">
|
||||
<return type="Variant">
|
||||
</return>
|
||||
<argument index="0" name="arg0" type="Vector2">
|
||||
</argument>
|
||||
<argument index="1" name="arg1" type="Control">
|
||||
</argument>
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="navigate_to_path">
|
||||
<return type="void">
|
||||
</return>
|
||||
<argument index="0" name="arg0" type="String">
|
||||
</argument>
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
</methods>
|
||||
<signals>
|
||||
<signal name="display_mode_changed">
|
||||
<description>
|
||||
</description>
|
||||
</signal>
|
||||
<signal name="file_removed">
|
||||
<argument index="0" name="file" type="String">
|
||||
</argument>
|
||||
<description>
|
||||
</description>
|
||||
</signal>
|
||||
<signal name="files_moved">
|
||||
<argument index="0" name="old_file" type="String">
|
||||
</argument>
|
||||
<argument index="1" name="new_file" type="String">
|
||||
</argument>
|
||||
<description>
|
||||
</description>
|
||||
</signal>
|
||||
<signal name="folder_moved">
|
||||
<argument index="0" name="old_folder" type="String">
|
||||
</argument>
|
||||
<argument index="1" name="new_file" type="String">
|
||||
</argument>
|
||||
<description>
|
||||
</description>
|
||||
</signal>
|
||||
<signal name="folder_removed">
|
||||
<argument index="0" name="folder" type="String">
|
||||
</argument>
|
||||
<description>
|
||||
</description>
|
||||
</signal>
|
||||
<signal name="inherit">
|
||||
<argument index="0" name="file" type="String">
|
||||
</argument>
|
||||
<description>
|
||||
</description>
|
||||
</signal>
|
||||
<signal name="instance">
|
||||
<argument index="0" name="files" type="PackedStringArray">
|
||||
</argument>
|
||||
<description>
|
||||
</description>
|
||||
</signal>
|
||||
</signals>
|
||||
<constants>
|
||||
</constants>
|
||||
</class>
|
|
@ -0,0 +1,23 @@
|
|||
# Makefile providing various facilities to manage translations
|
||||
|
||||
TEMPLATE = classes.pot
|
||||
POFILES = $(wildcard *.po)
|
||||
LANGS = $(POFILES:%.po=%)
|
||||
|
||||
all: update merge
|
||||
|
||||
update:
|
||||
@cd ../..; \
|
||||
python3 doc/translations/extract.py \
|
||||
--path doc/classes modules/*/doc_classes \
|
||||
--output doc/translations/$(TEMPLATE)
|
||||
|
||||
merge:
|
||||
@for po in $(POFILES); do \
|
||||
echo -e "\nMerging $$po..."; \
|
||||
msgmerge -w 79 -C $$po $$po $(TEMPLATE) > "$$po".new; \
|
||||
mv -f "$$po".new $$po; \
|
||||
done
|
||||
|
||||
check:
|
||||
@for po in $(POFILES); do msgfmt -c $$po -o /dev/null; done
|
File diff suppressed because it is too large
Load Diff
|
@ -8,7 +8,7 @@ from collections import OrderedDict
|
|||
|
||||
EXTRACT_TAGS = ["description", "brief_description", "member", "constant", "theme_item", "link"]
|
||||
HEADER = '''\
|
||||
# LANGUAGE translation of the Godot Engine class reference
|
||||
# LANGUAGE translation of the Godot Engine class reference.
|
||||
# Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur.
|
||||
# Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md).
|
||||
# This file is distributed under the same license as the Godot source code.
|
||||
|
@ -19,10 +19,26 @@ HEADER = '''\
|
|||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Godot Engine class reference\\n"
|
||||
"Report-Msgid-Bugs-To: https://github.com/godotengine/godot\\n"
|
||||
"MIME-Version: 1.0\\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\\n"
|
||||
"Content-Transfer-Encoding: 8-bit\\n"
|
||||
|
||||
'''
|
||||
# Some strings used by makerst.py are normally part of the editor translations,
|
||||
# so we need to include them manually here for the online docs.
|
||||
BASE_STRINGS = [
|
||||
"Description",
|
||||
"Tutorials",
|
||||
"Properties",
|
||||
"Methods",
|
||||
"Theme Properties",
|
||||
"Signals",
|
||||
"Enumerations",
|
||||
"Constants",
|
||||
"Property Descriptions",
|
||||
"Method Descriptions",
|
||||
]
|
||||
|
||||
## <xml-line-number-hack from="https://stackoverflow.com/a/36430270/10846399">
|
||||
import sys
|
||||
|
@ -166,7 +182,7 @@ def _strip_and_split_desc(desc, code_block_regions):
|
|||
total_indent = 0
|
||||
return desc_strip
|
||||
|
||||
## make catlog strings from xml elements
|
||||
## make catalog strings from xml elements
|
||||
def _make_translation_catalog(classes):
|
||||
unique_msgs = OrderedDict()
|
||||
for class_name in classes:
|
||||
|
@ -187,12 +203,17 @@ def _make_translation_catalog(classes):
|
|||
unique_msgs[desc_msg].append(desc_obj)
|
||||
return unique_msgs
|
||||
|
||||
## generate the catlog file
|
||||
## generate the catalog file
|
||||
def _generate_translation_catalog_file(unique_msgs, output):
|
||||
with open(output, 'w', encoding='utf8') as f:
|
||||
f.write(HEADER)
|
||||
for msg in BASE_STRINGS:
|
||||
f.write('#: doc/tools/makerst.py\n')
|
||||
f.write('msgid "{}"\n'.format(msg))
|
||||
f.write('msgstr ""\n\n')
|
||||
for msg in unique_msgs:
|
||||
if len(msg) == 0: continue ## ignore
|
||||
if len(msg) == 0 or msg in BASE_STRINGS:
|
||||
continue
|
||||
|
||||
f.write('#:')
|
||||
desc_list = unique_msgs[msg]
|
||||
|
@ -214,24 +235,28 @@ def _generate_translation_catalog_file(unique_msgs, output):
|
|||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--path", "-p", default=".", help="The directory containing XML files to collect.")
|
||||
parser.add_argument("--output", "-o", default="translation_catlog.pot", help="The path to the output file.")
|
||||
parser.add_argument("--path", "-p", nargs="+", default=".", help="The directory or directories containing XML files to collect.")
|
||||
parser.add_argument("--output", "-o", default="translation_catalog.pot", help="The path to the output file.")
|
||||
args = parser.parse_args()
|
||||
|
||||
output = os.path.abspath(args.output)
|
||||
if not os.path.isdir(os.path.dirname(output)) or not output.endswith('.pot'):
|
||||
print_error("Invalid output path: {}".format(output))
|
||||
exit(1)
|
||||
if not os.path.isdir(args.path):
|
||||
print_error("Invalid working directory path: {}".format(args.path))
|
||||
|
||||
classes = OrderedDict()
|
||||
for path in args.path:
|
||||
if not os.path.isdir(path):
|
||||
print_error("Invalid working directory path: {}".format(path))
|
||||
exit(1)
|
||||
|
||||
os.chdir(args.path)
|
||||
print("Current working dir: {}\n".format(os.getcwd()))
|
||||
print("\nCurrent working dir: {}".format(path))
|
||||
|
||||
classes = OrderedDict() ## dictionary of key=class_name, value=DescList objects
|
||||
_collect_classes_dir('.', classes)
|
||||
classes = OrderedDict(sorted(classes.items(), key = lambda kv: kv[0].lower() ))
|
||||
path_classes = OrderedDict() ## dictionary of key=class_name, value=DescList objects
|
||||
_collect_classes_dir(path, path_classes)
|
||||
classes.update(path_classes)
|
||||
|
||||
classes = OrderedDict(sorted(classes.items(), key = lambda kv: kv[0].lower()))
|
||||
unique_msgs = _make_translation_catalog(classes)
|
||||
_generate_translation_catalog_file(unique_msgs, output)
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ matches.sort()
|
|||
unique_str = []
|
||||
unique_loc = {}
|
||||
main_po = """
|
||||
# LANGUAGE translation of the Godot Engine editor
|
||||
# LANGUAGE translation of the Godot Engine editor.
|
||||
# Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur.
|
||||
# Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md).
|
||||
# This file is distributed under the same license as the Godot source code.
|
||||
|
@ -45,6 +45,8 @@ main_po = """
|
|||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Godot Engine editor\\n"
|
||||
"Report-Msgid-Bugs-To: https://github.com/godotengine/godot\\n"
|
||||
"MIME-Version: 1.0\\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\\n"
|
||||
"Content-Transfer-Encoding: 8-bit\\n"
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue