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

Using RegEx for Variants #4888

Closed
ilocit opened this issue Nov 20, 2020 · 8 comments
Closed

Using RegEx for Variants #4888

ilocit opened this issue Nov 20, 2020 · 8 comments
Labels
question This is more a question for the support than an issue.

Comments

@ilocit
Copy link
Contributor

ilocit commented Nov 20, 2020

We use weblate to translate amongst other things also SAP content.
SAP text lines can be exported from the SAP system as e.g. XLIFF.

There are special object types within an SAP system. One very common one is a so called Data Element.
Since the text of a Data Element can be used in different context, each Data Element usually has 5 texts, each with a different length restriction.

So my idea was now of course to use Variants to group these for translation to make them easily recognizable as belonging together.

This is what it looks like in the SAP GUI:
image

And here is the set of five strings in Weblate; but not yet grouped as variants:
image

Since there is a pattern that can be used, I specified this RegEx in Settings / Translations / Variants:
//(SCRTEXT_S|SCRTEXT_M|SCRTEXT_L|REPTEXT|DDTEXT)

An example of the keys of such a Data Element would be

DTEL///ABSD/DE_INTEND_POSTBACKGR//SCRTEXT_M 00001
DTEL///ABSD/DE_INTEND_POSTBACKGR//REPTEXT 00001
DTEL///ABSD/DE_INTEND_POSTBACKGR//SCRTEXT_L 00001
DTEL///ABSD/DE_INTEND_POSTBACKGR//SCRTEXT_S 00001
DTEL///ABSD/DE_INTEND_POSTBACKGR//DDTEXT 00001
DTEL///ABSD/DE_INTEND_POSTBACKGR//SCRTEXT_M 00001

But the grouping does not work that way.
Is this because there is no "base" Key which ends with "DTEL///ABSD/DE_INTEND_POSTBACKGR"?
The "root" (unabbreviated text) would ideally be DTEL///ABSD/DE_INTEND_POSTBACKGR//DDTEXT or DTEL///ABSD/DE_INTEND_POSTBACKGR//REPTEXT

Thanks for any hints and suggestions.

@ilocit ilocit added the question This is more a question for the support than an issue. label Nov 20, 2020
@github-actions
Copy link

This issue looks more like a support question than an issue. We strive to answer these reasonably fast, but purchasing the support subscription is not only more responsible and faster for your business but also makes Weblate stronger. In case your question is already answered, making a donation is the right way to say thank you!

@nijel
Copy link
Member

nijel commented Nov 20, 2020

I think it should work. The strings are grouped based on the key after the variant regex is removed.

@ilocit
Copy link
Contributor Author

ilocit commented Nov 20, 2020

Right, it should, shouldn't it? But it doesn't....

When does this setting kick in? Only with brandnew components during the initialization, or also as kind of an Update to an existing component and/or for Components which are added via Auto Discovery after the setting was set for the "template" component? Maybe that is the problem we are facing?

Basically, can this setting be added and set to action also retroctively?

@nijel
Copy link
Member

nijel commented Nov 20, 2020

Whenever you change the regexp the variants mapping should be updated in the background. Maybe there is some issue with Celery and it doesn't process the queue? WeblateOrg/docker#887 seems to indicate that...

@ilocit
Copy link
Contributor Author

ilocit commented Nov 20, 2020

Well, I see this little icon that the Components are being updated. But once they are finished, nothing has changed. I still see all Strings seperate and not grouped:

image

No Variants tab displayed @

nijel added a commit that referenced this issue Nov 21, 2020
nijel added a commit that referenced this issue Nov 21, 2020
@nijel
Copy link
Member

nijel commented Nov 21, 2020

I've just added tests to cover this case and it seems to work fine. Also it showed up correctly in my test project when using keys and regexp you've posted in the initial comment:

obrazek

@ilocit
Copy link
Contributor Author

ilocit commented Nov 21, 2020

Thanks for doing all these tests, @nijel!

I also did some further tests. It seems that the issue is related to the number of trailing spaces which follow the expressions in the RegEx. The pattern is that REPTEXT is followed by 3 spaces and DDTEXT by 4. The others (_S,_M,_L) all have only one trailing space.

When I add those three or four spaces to the RegEx, weblate creates two groups of variants, when I then add a single space to each of the other three expressions, it WORKS! ;-)
(working pattern is //(REPTEXT |DDTEXT |SCRTEXT_S |SCRTEXT_M |SCRTEXT_L ))

A bit strange. I did not expect this with the RegEx, but perhaps it is my still limited knowledge of RegEx...

Thanks a mil for your help - problem solved.
Have a wonderful weekend.

@ilocit ilocit closed this as completed Nov 21, 2020
@github-actions
Copy link

The issue you have reported is resolved now. If you don’t feel it’s right, please follow it’s labels to get a clue and take further steps.

  • In case you see a similar problem, please open a separate issue.
  • If you are happy with the outcome, don’t hesitate to support Weblate by making a donation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question This is more a question for the support than an issue.
Projects
None yet
Development

No branches or pull requests

2 participants