perpetualKid / GetText.NET

A .NET Standard cross-platform implementation of GNU Gettext
Other
34 stars 11 forks source link

Wrong text extraction #48

Open PatrizioG opened 1 year ago

PatrizioG commented 1 year ago

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");

CallingGetText.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 ""
perpetualKid commented 1 year ago

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?

PatrizioG commented 1 year ago

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

perpetualKid commented 1 year ago

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?

PatrizioG commented 1 year ago

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

Menelion commented 8 months ago

@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!

perpetualKid commented 7 months ago

@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