-
-
Notifications
You must be signed in to change notification settings - Fork 22k
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
[Editor] Fix parsing translations in EditorTranslationParserPlugin
#99297
[Editor] Fix parsing translations in EditorTranslationParserPlugin
#99297
Conversation
To illustrate the issue, this is the signature of the related virtual void _parse_file(const String &p_path, const TypedArray<String> &p_msgids, const TypedArray<Array> &p_msgids_context_plural); Haven't generated the headers for the current state but |
I'm not familiar with the GDExtension issue, but it looks good to me as long as
|
That makes sense, will test some alternatives for deprecation and update as needed I'm not familiar enough with the code here to say if merging the two methods into one is feasible, but if it is might merging the two, dropping The new method could be That way we could possibly detect if Would depend on if we consider deprecation worth it, unsure what happens in other languages but it is possible to use it in godot-cpp but requires casting, I don't know how it works in C# though so confirming how the current methods work or don't work for plugins made in C# would be good It does seem that these cases do work with plugins in GDScript so that's a reason to deprecate over entirely replacing, but will test with GDScript soon to confirm |
I haven't tested personally but since Arrays in C# are reference types I imagine they may work. #99195 uses the method so, assuming the PR works, it would prove that the method works in C#. Also, how is the GDExtension validation not complaining about breaking compatibility? Does it not check virtual methods? |
I guess it depends on how we handle other cases in #92175. Yes, the fact that it seems to work in GDScript and C# is an argument for deprecation instead of removal/replacement. However, I don't think |
I'll see about some options today for this and #92175 |
Will try investigate this properly this week Edit: haven't been able to find the time to investigate this yet but will try next week |
Bump :) This seems to be important to merge before 4.4, as IIUC it's fixing the return type of a newly exposed function. |
Agreed, will try get to this before the end of the week! |
Working on this and testing out making a new |
Gotten it to work, and works correctly with existing code and plugins, just tested the plugin in GDScript so couldn't test the deprecation The one question is if we keep Edit: Will update the documentation after we've decided on a solution |
ae2d0ec
to
9ae23f4
Compare
EditorTranslationParserPlugin._get_comments
EditorTranslationParserPlugin
9ae23f4
to
7d041eb
Compare
<method name="_get_recognized_extensions" qualifiers="virtual const"> | ||
<return type="PackedStringArray" /> | ||
<description> | ||
Gets the list of file extensions to associate with this parser, e.g. [code]["csv"][/code]. | ||
</description> | ||
</method> | ||
<method name="_parse_file" qualifiers="virtual"> | ||
<return type="void" /> | ||
<return type="PackedStringArray[]" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The return value will need explanation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, see above:
Will update the documentation after we've decided on a solution
WDYT about this solution @dalexeev? This builds upon your previous PR, changing the API, so if wanted it would be good to get this merged for 4.4. |
7d041eb
to
43eb929
Compare
Ping @dalexeev |
43eb929
to
0172918
Compare
0172918
to
046044a
Compare
Pushed a new solution, the order is different from the one suggested in the example above, see: This is to match the old method order, with Will write the documentation and update the example if this new solution is approved The above test project also contains some examples of the engine systems for the same to confirm it works correctly when parsing scenes and GDScript |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, just a few minor notes and incomplete documentation.
@@ -146,8 +136,7 @@ void GDScriptEditorTranslationParserPlugin::_add_id_ctx_plural(const Vector<Stri | |||
return; | |||
} | |||
|
|||
ids_ctx_plural->push_back(p_id_ctx_plural); | |||
ids_ctx_plural_comment.push_back(comment); | |||
translations->push_back({ p_id_ctx_plural[0], p_id_ctx_plural[1], p_id_ctx_plural[2], comment }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not directly related to this PR, but I would replace Vector<String>
with a 3-string struct. This code is safe, but relies on the implicit assumption that the vector is always 3-element:
godot/modules/gdscript/editor/gdscript_translation_parser_plugin.cpp
Lines 351 to 352 in e567f49
Vector<String> id_ctx_plural; | |
id_ctx_plural.resize(3); |
919ab4a
to
7484967
Compare
Documentation added and updated, need help to confirm the C# part of the examples as I'm unfamiliar with C# and how to handle packed arrays and similar there |
Merged `_get_comments` into `_parse_file` and changed to using a returned `Array[PackedStringArray]` instead.
7484967
to
fec3d9e
Compare
Thanks! |
Thank you! |
Method used passed arguments as return data which does not work with extensions, switched to using a
Dictionary
return. This might work in extensions after fixing typed array copying, but unsure, and I think this return format is safer in any case to use, and is the standard in most of the virtual methods like this (also any binding for this will have to useconst_cast
as the resulting methods will pass asconst TypedArray<String> &
)Follow-up to:
TRANSLATORS:
andNO_TRANSLATE
comments #98099See also: