Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow EditorTranslationParserPlugins to provide comments for POT generation #8917

Closed
nathanhoad opened this issue Jan 20, 2024 · 3 comments · Fixed by godotengine/godot#98099
Milestone

Comments

@nathanhoad
Copy link

nathanhoad commented Jan 20, 2024

Describe the project you are working on

I make Dialogue Manager which uses an EditorTranslationParserPlugin to export translatable lines of dialogue into the POT file.

Describe the problem or limitation you are having in your project

I'm in the process of supporting doc-style comments on lines of dialogue that can be included when exporting translations. This is (mostly) already possible with the CSV option but not possible if using POT files.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

I propose adding an optional fourth item to the msgids_context_plural array in EditorTranslationParserPlugin::parse_file that can be used to provide comments.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

Anyone implementing an EditorTranslationParserPlugin would be able to add a fourth item to the msgids_context_plural array to provide a comment. That comment (if provided) would then be added to the generated POT file

extends EditorTranslationParserPlugin

func _parse_file(path: String, msgids: Array, msgids_context_plural: Array) -> void:
	# ...load some file, for example a dialogue file...

	for dialogue_line: Dictionary in dialogue_lines:
		# Here the line's comment would be passed as the optional fourth item in the array.
		msgids_context_plural.append([line.text, line.context, "", line.comment])
# This is the provided comment. It might be used to provide a hint
# like "the chicken question is the set up to a really basic joke".
#: examples/dialogue.dialogue
msgid "Hi, I'm Nathan. Why did the chicken cross the road?"
msgstr ""

If this enhancement will not be used often, can it be worked around with a few lines of script?

It might be used by any addon that wants to provide extra help for translators with user generated strings.

As far as I'm aware a workaround isn't currently possible.

Is there a reason why this should be core and not an add-on in the asset library?

As far as I'm aware it's not currently possible to do with an addon.

@aXu-AP
Copy link

aXu-AP commented Oct 11, 2024

Should similiar functionality also be included in tr() etc.?

@Calinou
Copy link
Member

Calinou commented Oct 11, 2024

Should similiar functionality also be included in tr() etc.?

tr() already has an optional second parameter for a context, but I agree it could have an optional third parameter that would be read as a comment. In this case, you'd use an empty string for the context if you don't want to use a specific context.

@dalexeev
Copy link
Member

See also:

Should similiar functionality also be included in tr() etc.?

See #8555 (comment).

I think we could implement comment extraction in GDScriptEditorTranslationParserPlugin, like:

# TRANSLATORS: Here a comment for translators.
text = tr("Message")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants