Results 1 to 8 of 8

Thread: How to mark Property name in Q_PROPERTY for language change??

  1. #1
    Join Date
    Oct 2006
    Location
    Bangalore
    Posts
    32
    Qt products
    Qt4
    Platforms
    Windows

    Question How to mark Property name in Q_PROPERTY for language change??

    Hi,

    We have tr(), QT_TRANSLATE_NOOP, QT_TR_NOOP for marking a string to be eligible for translation.

    I am facing problem when I want to mark a property name for language change.

    For ex:
    Q_PROPERTY(QString Width READ width WRITE setWidth)

    If I change the language to say German, the property name should actually be "Weite" and not "Width".

    How can I mark the type name or property name for language change?

    Regards,

  2. #2
    Join Date
    Feb 2007
    Location
    Karlsruhe, Germany
    Posts
    469
    Thanks
    17
    Thanked 90 Times in 88 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to mark Property name in Q_PROPERTY for language change??

    I have never used translations before, so I can't be of big help. But have you looked at, how qt translates its ui-files? It uses QApplication::translate with some context. You could do the same. You probably would have to insert/mark the translations manually though, or find out how qt does that for UI-captions ..

    What I can help you with, is, that "Width" translates to "Breite" in german. "Weite" is not used in that context.

    Johannes

  3. #3
    Join Date
    Oct 2006
    Location
    Bangalore
    Posts
    32
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to mark Property name in Q_PROPERTY for language change??

    Hi Johannes,

    Thanks for the reply.

    I set lang to 'de' and launched the Designer to check whether the property names have been translated correctly to German.
    I placed a pushbutton on the form and checked whether the property names are changed to German. Unfortunately, none of the property names are translated. But, when I expand any property, for example "Geometry", then the items under that( height and width )are translated to German. I am confused now.

    Regards,
    Ankitha

  4. #4
    Join Date
    Feb 2007
    Location
    Karlsruhe, Germany
    Posts
    469
    Thanks
    17
    Thanked 90 Times in 88 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to mark Property name in Q_PROPERTY for language change??

    Mmh.. well that seems to be a problem in designer.. But still you could try and look up the sourcecode of designer to see how the subproperties get translated!

    Why do you want to translate the properties anyway? Are you building a propertyeditor for the enduser? Or do you want to use the translated-properties in QtScript?

    Good luck!

    Johannes

  5. #5
    Join Date
    Oct 2006
    Location
    Bangalore
    Posts
    32
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to mark Property name in Q_PROPERTY for language change??

    Yeah, I want to provide a property editor to the end user.
    I shall look into designer's code to check how subproperties get translated there.

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to mark Property name in Q_PROPERTY for language change??

    Quote Originally Posted by Ankitha Varsha View Post
    Unfortunately, none of the property names are translated.
    Property names can't be translated because they are identifiers. Just as you don't translate C++ keywords, variable and function names to german when you compile using a compiler with german locale.

    But, when I expand any property, for example "Geometry", then the items under that( height and width )are translated to German.
    That's because these are not properties but fields for property types that are interpreted by Designer (that's why they can be translated).

    I would really advise against trying to override this behaviour unless you consider yourself an expert on Designer property sheet extensions and you will be the only one using the widget you wish to translate properties for (or your users will get a headache trying to reference a "breite" property in their code instead of "width".

  7. #7
    Join Date
    Feb 2007
    Location
    Karlsruhe, Germany
    Posts
    469
    Thanks
    17
    Thanked 90 Times in 88 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to mark Property name in Q_PROPERTY for language change??

    Hi Wysota!

    I think its not about using those translated properties in code, but to provide the end-user a runtime property editor for some objects. And this property editor shall use translated property names.

    I suggested to use QCoreApplication::translate manually on each property name, when the property editor is populated. That would imply to manually add the translations..

    Can you think of a more elegant way? At least to mark/make the required strings available to linguist..

    Johannes

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to mark Property name in Q_PROPERTY for language change??

    Quote Originally Posted by JohannesMunk View Post
    I think its not about using those translated properties in code, but to provide the end-user a runtime property editor for some objects.
    To do it in a sane way you'd have to reprogram half of Designer. This is of course possible but it's much easier to use QtPropertyBrowser solution if you don't require the actual "design" capabilities of Designer.

    Can you think of a more elegant way?
    Yes, implement a "Designer Property Sheet Extension".

    At least to mark/make the required strings available to linguist..
    Linguist will happily use QT_TR_NOOP or strings from the property sheet extension.

Similar Threads

  1. Change UI Language of Qt Tools
    By shentian in forum Qt Tools
    Replies: 4
    Last Post: 10th July 2013, 08:45
  2. how can i mark points on top of a Image?
    By montamer in forum Qt Programming
    Replies: 2
    Last Post: 2nd April 2010, 12:53
  3. how change language at runtime?
    By mattia in forum Newbie
    Replies: 3
    Last Post: 14th November 2007, 18:36
  4. QTextEdit and mark Text
    By J-jayz-Z in forum Qt Programming
    Replies: 12
    Last Post: 28th September 2007, 00:14
  5. Replies: 8
    Last Post: 15th May 2007, 09:21

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.