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

"QObject::tr" does not work #5

Closed
glixx opened this issue Aug 9, 2015 · 12 comments
Closed

"QObject::tr" does not work #5

glixx opened this issue Aug 9, 2015 · 12 comments
Assignees
Labels
Milestone

Comments

@glixx
Copy link
Member

glixx commented Aug 9, 2015

It marks string for translation for lupdate, but don't allow to use translated string.
https://forum.qt.io/topic/33568/qt-tr-not-working-if-i-am-using-in-static-member
Please find another way instead of "QObject::tr" for static members, but keep lupdate as workable.

@kaa-ching
Copy link
Member

Labelled this as an enhancement - TBE will work if not fixed, but some strings are not translated.

@kaa-ching
Copy link
Member

I didn't find any issues using either
git grep static.*tr.*\(
or using
git grep QObject::tr
All occurences of the latter seem to be present in the i18n/*.ts files.

@glixx
Copy link
Member Author

glixx commented Aug 11, 2015

Yes, all strings are present in i18n/*.ts files, but it's not enough. QObject::tr allows to mark strings for lupdate, but no more. Sometimes QObject::tr is workable, but not always.
If you finish Dutch translation 100% you will see this issue. I have 100% for Russian and I see big problem with translations.
You did not understand this issue, grep will show OK, ts files is OK, but bug is present anyway.

@kaa-ching kaa-ching reopened this Aug 11, 2015
@kaa-ching
Copy link
Member

OK, I've run with Russian. I see that tool tips for internal objects do not show translated text.
e.g. in level "Marble boulevard", CircleObject.cpp:65 and PolyObject.cpp:119 are not shown translated.
Is that what you are looking at?

@kaa-ching kaa-ching added bug and removed enhancement labels Aug 11, 2015
@kaa-ching kaa-ching added this to the Milestone A milestone Aug 11, 2015
@kaa-ching kaa-ching self-assigned this Aug 11, 2015
@kaa-ching
Copy link
Member

Can you verify that commit [1897c8a] solves the issue for all normal balls?
I think it does :-)

kaa-ching added a commit that referenced this issue Aug 15, 2015
@kaa-ching
Copy link
Member

Somehow, I'm under the impression that what is working for CircleObjects, is not working for RectObjects and PolyObjects...
The strings do not appear in the *.ts files.
Did I forget something?

@glixx
Copy link
Member Author

glixx commented Aug 15, 2015

Can you verify that commit [1897c8a] solves the issue for all normal balls?

Yes.

Somehow, I'm under the impression that what is working for CircleObjects, is not working for RectObjects and PolyObjects...

lupdate works for RectObjects, but not for CircleObjects, PolyObjects. I don't know why.

@kaa-ching
Copy link
Member

lupdate works for RectObjects, but not for CircleObjects, PolyObjects. I don't know why.

So apparently it only works for one file, not for more. In my case, it chose CircleObjects, in your case it chose RectObjects... Sigh...

@glixx
Copy link
Member Author

glixx commented Aug 19, 2015

My mistake.
I found reason:

diff -ur tbe-0.9-git8b8c580.orig/src/model/PolyObject.cpp tbe-0.9-git8b8c580/src/model/PolyObject.cpp
--- tbe-0.9-git8b8c580.orig/src/model/PolyObject.cpp    2015-08-15 21:36:20.000000000 +0300
+++ tbe-0.9-git8b8c580/src/model/PolyObject.cpp 2015-08-20 00:45:00.000000000 +0300
@@ -44,8 +44,8 @@

 static AbstractPolyObjectFactory theBowlingPinFactory(
    "BowlingPin",
-   QT_TRANSLATE_NOOP(AbstractPolyObjectFactory, "Bowling Pin"),
-   QT_TRANSLATE_NOOP(AbstractPolyObjectFactory, "Bowling pins are meant to be run "
+   QT_TRANSLATE_NOOP("AbstractPolyObjectFactory", "Bowling Pin"),
+   QT_TRANSLATE_NOOP("AbstractPolyObjectFactory", "Bowling pins are meant to be run "
                "over - and most people prefer to do that using "
                "a Bowling Ball."),
    "BowlingPin",
@@ -57,8 +57,8 @@

 static AbstractPolyObjectFactory theSkyhookFactory(
    "Skyhook",
-   QT_TRANSLATE_NOOP(AbstractPolyObjectFactory, "Skyhook"),
-   QT_TRANSLATE_NOOP(AbstractPolyObjectFactory, "A skyhook just hangs in the air. And you can hang a "
+   QT_TRANSLATE_NOOP("AbstractPolyObjectFactory", "Skyhook"),
+   QT_TRANSLATE_NOOP("AbstractPolyObjectFactory", "A skyhook just hangs in the air. And you can hang a "
                "lot of weight on it!"),
    "Skyhook",
    "(-0.03,-0.07)=(0.01,-0.11)=(0.05,-0.11)=(0.1,-0.05)=(0.1,-0.02)"
@@ -67,40 +67,40 @@

 static AbstractPolyObjectFactory theWeightFactory(
    "Weight",
-   QT_TRANSLATE_NOOP(AbstractPolyObjectFactory, "Weight"),
-   QT_TRANSLATE_NOOP(AbstractPolyObjectFactory, "A serious mass. As heavy as it looks!"),
+   QT_TRANSLATE_NOOP("AbstractPolyObjectFactory", "Weight"),
+   QT_TRANSLATE_NOOP("AbstractPolyObjectFactory", "A serious mass. As heavy as it looks!"),
    "Weight",
    "(-0.20,-0.20)=(0.20,-0.20)=(0.06,0.20)=(-0.06,0.20)",
    0.40, 0.40, 10.0, 0.3 );

 static AbstractPolyObjectFactory theLeftRampFactory(
    "LeftRamp",
-   QT_TRANSLATE_NOOP(AbstractPolyObjectFactory, "Left Ramp"),
-   QT_TRANSLATE_NOOP(AbstractPolyObjectFactory, "This is a ramp. The left is lower than the right, so things slide to the left."),
+   QT_TRANSLATE_NOOP("AbstractPolyObjectFactory", "Left Ramp"),
+   QT_TRANSLATE_NOOP("AbstractPolyObjectFactory", "This is a ramp. The left is lower than the right, so things slide to the left."),
    "LeftRamp",
        "(-0.5,-0.46)=(-0.5,-0.5)=(0.13,-0.5)=(0.5,0.5)",
    1.0, 1.0, 0.0, 0.2 );

 static AbstractPolyObjectFactory theRightRampFactory(
    "RightRamp",
-   QT_TRANSLATE_NOOP(AbstractPolyObjectFactory, "Right Ramp"),
-   QT_TRANSLATE_NOOP(AbstractPolyObjectFactory, "This is a ramp. The left is higher than the right, so things slide to the right."),
+   QT_TRANSLATE_NOOP("AbstractPolyObjectFactory", "Right Ramp"),
+   QT_TRANSLATE_NOOP("AbstractPolyObjectFactory", "This is a ramp. The left is higher than the right, so things slide to the right."),
    "RightRamp",
        "(-0.5,0.5)=(-0.13,-0.5)=(0.5,-0.5)=(0.5,-0.46)",
    1.0, 1.0, 0.0, 0.2 );

 static AbstractPolyObjectFactory theLeftWedgeFactory(
    "LeftWedge",
-   QT_TRANSLATE_NOOP(AbstractPolyObjectFactory, "Left Wedge"),
-   QT_TRANSLATE_NOOP(AbstractPolyObjectFactory, "This is a wedge. The left is lower than the right, so things slide to the left."),
+   QT_TRANSLATE_NOOP("AbstractPolyObjectFactory", "Left Wedge"),
+   QT_TRANSLATE_NOOP("AbstractPolyObjectFactory", "This is a wedge. The left is lower than the right, so things slide to the left."),
    "birch-wedge-left",
        "(-0.5,-0.46)=(-0.5,-0.5)=(0.5,-0.5)=(0.5,0.5)",
    1.0, 1.0, 0.0, 0.2 );

 static AbstractPolyObjectFactory theRightWedgeFactory(
    "RightWedge",
-   QT_TRANSLATE_NOOP(AbstractPolyObjectFactory, "Right Wedge"),
-   QT_TRANSLATE_NOOP(AbstractPolyObjectFactory, "This is a wedge. The left is higher than the right, so things slide to the right."),
+   QT_TRANSLATE_NOOP("AbstractPolyObjectFactory", "Right Wedge"),
+   QT_TRANSLATE_NOOP("AbstractPolyObjectFactory", "This is a wedge. The left is higher than the right, so things slide to the right."),
    "birch-wedge-right",
        "(-0.5,0.5)=(-0.5,-0.5)=(0.5,-0.5)=(0.5,-0.46)",
    1.0, 1.0, 0.0, 0.2 );
@@ -109,8 +109,8 @@
 // on both the inside and the outside - you can use both if you want :-)
 static AbstractPolyObjectFactory the40QuarterArcFactory(
    "QuarterArc40",
-   QT_TRANSLATE_NOOP(AbstractPolyObjectFactory, "Quarter Arc Small"),
-   QT_TRANSLATE_NOOP(AbstractPolyObjectFactory, "This is a quarter arc. Or ninety degrees, or 1.57 radians if you want."),
+   QT_TRANSLATE_NOOP("AbstractPolyObjectFactory", "Quarter Arc Small"),
+   QT_TRANSLATE_NOOP("AbstractPolyObjectFactory", "This is a quarter arc. Or ninety degrees, or 1.57 radians if you want."),
    "QuarterArc",
    "(0.100,-.200)=(0.200,-.200)=(0.180,-.076)=(0.085,-.107);"
    "(0.085,-.107)=(0.180,-.076)=(0.124,0.035)=(0.043,-.024);"
@@ -123,8 +123,8 @@
 // on both the inside and the outside - you can use both if you want :-)
 static AbstractPolyObjectFactory the80QuarterArcFactory(
    "QuarterArc80",
-   QT_TRANSLATE_NOOP(AbstractPolyObjectFactory, "Quarter Arc Large"),
-   QT_TRANSLATE_NOOP(AbstractPolyObjectFactory, "This is a quarter arc. Or ninety degrees, or 1.57 radians if you want."),
+   QT_TRANSLATE_NOOP("AbstractPolyObjectFactory", "Quarter Arc Large"),
+   QT_TRANSLATE_NOOP("AbstractPolyObjectFactory", "This is a quarter arc. Or ninety degrees, or 1.57 radians if you want."),
    "QuarterArc80",
    "( 0.300,-0.400)=( 0.400,-0.400)=( 0.388,-0.261)=( 0.289,-0.278);"
    "( 0.289,-0.278)=( 0.388,-0.261)=( 0.352,-0.126)=( 0.258,-0.161);"
diff -ur tbe-0.9-git8b8c580.orig/src/model/RectObject.cpp tbe-0.9-git8b8c580/src/model/RectObject.cpp
--- tbe-0.9-git8b8c580.orig/src/model/RectObject.cpp    2015-08-15 21:36:20.000000000 +0300
+++ tbe-0.9-git8b8c580/src/model/RectObject.cpp 2015-08-20 00:45:39.000000000 +0300
@@ -49,27 +49,27 @@
 // anImageName,   aWidth,aHeight,  aMass,  aBounciness

 static AbstractRectObjectFactory theDomRedFactory("DominoRed",
-   QT_TRANSLATE_NOOP(AbstractRectObjectFactory, "Domino (Red)"),
-   QT_TRANSLATE_NOOP(AbstractRectObjectFactory, "The famous plastic red domino stone"),
+   QT_TRANSLATE_NOOP("AbstractRectObjectFactory", "Domino (Red)"),
+   QT_TRANSLATE_NOOP("AbstractRectObjectFactory", "The famous plastic red domino stone"),
    "DominoRed", 0.1, 0.5, 2.5, 0.1 );

 static AbstractRectObjectFactory theDomBlueFactory("DominoBlue",
-   QT_TRANSLATE_NOOP(AbstractRectObjectFactory, "Domino (Blue)"),
-   QT_TRANSLATE_NOOP(AbstractRectObjectFactory, "The famous plastic blue domino stone"),
+   QT_TRANSLATE_NOOP("AbstractRectObjectFactory", "Domino (Blue)"),
+   QT_TRANSLATE_NOOP("AbstractRectObjectFactory", "The famous plastic blue domino stone"),
    "DominoBlue", 0.1, 0.5, 2.5, 0.1 );

 static AbstractRectObjectFactory theDomGreenFactory("DominoGreen",
-   QT_TRANSLATE_NOOP(AbstractRectObjectFactory, "Domino (Green)"),
-   QT_TRANSLATE_NOOP(AbstractRectObjectFactory, "The famous plastic green domino stone"),
+   QT_TRANSLATE_NOOP("AbstractRectObjectFactory", "Domino (Green)"),
+   QT_TRANSLATE_NOOP("AbstractRectObjectFactory", "The famous plastic green domino stone"),
    "DominoGreen", 0.1, 0.5, 2.5, 0.1 );

 static AbstractRectObjectFactory theFloorFactory("Floor",
-   QT_TRANSLATE_NOOP(AbstractRectObjectFactory, "Floor"),
+   QT_TRANSLATE_NOOP("AbstractRectObjectFactory", "Floor"),
    "",
    "used_wood_bar", 1.0, 0.1, 0.0, 0.1 );

 static AbstractRectObjectFactory theWallFactory("Wall",
-   QT_TRANSLATE_NOOP(AbstractRectObjectFactory, "Wall"),
+   QT_TRANSLATE_NOOP("AbstractRectObjectFactory", "Wall"),
    "",
    "oldbrick", 0.2, 1.0, 0.0, 0.05 );

@kaa-ching
Copy link
Member

Changeset 825db79 (which I had to type again because copy/paste appears to not work. Thanks, github) resolves this issue.

@glixx
Copy link
Member Author

glixx commented Aug 20, 2015

QObject::tr is present in code yet. Are you sure it works? I'm not.
QT_TRANSLATE_NOOP works always, but QObject::tr not always.

@glixx
Copy link
Member Author

glixx commented Aug 20, 2015

Tested, issue was fixed.
It seems others QObject::tr are workable.

@the-butterfly-effect the-butterfly-effect locked and limited conversation to collaborators Oct 29, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants