GetText.NET icon indicating copy to clipboard operation
GetText.NET copied to clipboard

Wrong text extraction

Open PatrizioG opened this issue 2 years ago • 6 comments

GetText.Extractor version: 1.8.7+bff42fb416

In our code we concatenate strings in this way: lblArtCode.Text += " - " + ds.Current.Name;

and the correct call to extract is: localizer.TextTranslator("Correct call to my localization method");

Calling GetText.Extractor -as TextTranslator erroneously add the string " - " to messages.pot

#: ..\example.cs:1
msgid " - "
msgstr ""

#: ..\example.cs:2
msgid "Correct call to my localization method"
msgstr ""

PatrizioG avatar Mar 08 '23 12:03 PatrizioG

see https://github.com/perpetualKid/GetText.NET/wiki/Extractor-Intro last chapter

The Extractor will automatically export all literal string assignments from .Text/HeaderText/ToolTipText properties, which are typically saved in the (Form1).Designer.cs files

Is the issue that the " - " string is unnecessarily extracted and stored in the .pot file?

perpetualKid avatar Mar 08 '23 14:03 perpetualKid

Exactly, that's the problem. Is there a way to perform recognition of those properties only on *.Designer.cs files?

PatrizioG avatar Mar 08 '23 15:03 PatrizioG

right now it's hardcoded to extract strings from any of the listed properties. While I would not like to limited extraxting these form .designer.cs files only (there are often cases in Winform development where such properties are set in regular .cs files also), I concur to make it configurable/explicit option (via extra cli parameter) whether such strings should be extracted.

Given though this is irritating but otherwise harmless, not sure if an enhancement will justify a new version to be released. Is this causing any blocking issues in your workflow?

perpetualKid avatar Mar 08 '23 18:03 perpetualKid

Don't worry, is not urgent. I have currently made a workaround within the parser to check those properties only on files with the extension *.Designer.cs. Thank you for your helpfulness

PatrizioG avatar Mar 08 '23 22:03 PatrizioG

@perpetualKid We have a similar problem where the Extractor extracts all Text properties even for invisible items and so on.
Would it be possible to add some kind of attribute or other indicator that this particular control, like this toolStripLabel, should be ignored by the Extractor? Thanks!

Menelion avatar Mar 14 '24 11:03 Menelion

@perpetualKid We have a similar problem where the Extractor extracts all Text properties even for invisible items and so on. Would it be possible to add some kind of attribute or other indicator that this particular control, like this toolStripLabel, should be ignored by the Extractor? Thanks!

certainly possible, code contributions are welcome

perpetualKid avatar Mar 31 '24 11:03 perpetualKid