parameters: (context, text, utf8_decode=False)
docstring: r"""Translate the text using the Qt translate function.
  
      It wraps around `QtGui.QApplication.translate`,
      which is the same as `QtCore.QCoreApplication.translate`.
  
      Parameters
      ----------
      context: str
          In C++ it is typically a class name.
          But it can also be any other string to categorize the translation,
          for example, the name of a workbench, tool, or function
          that is being translated. Usually it will be the name
          of the workbench.
  
      text: str
          Text that will be translated. It could be a single word,
          a full sentence, paragraph, or multiple paragraphs with new lines.
          Usually the last endline character '\\n'
          that finishes the string doesn't need to be included
          for translation.
  
      utf8_decode: bool
          It defaults to `False`.
          This must be set to `True` to indicate that the `text`
          is an `'utf8'` encoded string, so it should be returned as such.
          This option is ignored when using Python 3
          as with Python 3 all strings are `'utf8'` by default.
  
      Returns
      -------
      str
          A unicode string returned by `QtGui.QApplication.translate`.
  
          If `utf8_decode` is `True`, the resulting string will be encoded
          in `'utf8'`, and a `bytes` object will be returned.
          ::
              Qtranslate = QtGui.QApplication.translate
              return Qtranslate(context, text, None).encode("utf8")
  
      Unicode strings
      ---------------
      Whether it is Qt4 or Qt5, the `translate` function
      always returns a unicode string.
      The difference is how it handles the input.
  
      Reference: https://pyside.github.io/docs/pyside/PySide/QtCore/
  
      In Qt4 the translate function has a 4th parameter to define the encoding
      of the input string.
  
      >>> QtCore.QCoreApplication.translate(context, text, None, UnicodeUT8)
      >>> QtGui.QApplication.translate(context, text, None, UnicodeUT8)
  
      Reference: https://doc.qt.io/qtforpython/PySide2/QtCore
  
      In Qt5 the strings are always assumed unicode, so the 4th parameter
      is for a different use, and it is not used.
  
      >>> QtCore.QCoreApplication.translate(context, text, None)
      >>> QtGui.QApplication.translate(context, text, None)
docstring_summary: r"""Translate the text using the Qt translate function.
docstring_tokens: r Translate the text using the Qt translate function .
function: def translate(context, text, utf8_decode=False):
      r"""Translate the text using the Qt translate function.
  
      It wraps around `QtGui.QApplication.translate`,
      which is the same as `QtCore.QCoreApplication.translate`.
  
      Parameters
      ----------
      context: str
          In C++ it is typically a class name.
          But it can also be any other string to categorize the translation,
          for example, the name of a workbench, tool, or function
          that is being translated. Usually it will be the name
          of the workbench.
  
      text: str
          Text that will be translated. It could be a single word,
          a full sentence, paragraph, or multiple paragraphs with new lines.
          Usually the last endline character '\\n'
          that finishes the string doesn't need to be included
          for translation.
  
      utf8_decode: bool
          It defaults to `False`.
          This must be set to `True` to indicate that the `text`
          is an `'utf8'` encoded string, so it should be returned as such.
          This option is ignored when using Python 3
          as with Python 3 all strings are `'utf8'` by default.
  
      Returns
      -------
      str
          A unicode string returned by `QtGui.QApplication.translate`.
  
          If `utf8_decode` is `True`, the resulting string will be encoded
          in `'utf8'`, and a `bytes` object will be returned.
          ::
              Qtranslate = QtGui.QApplication.translate
              return Qtranslate(context, text, None).encode("utf8")
  
      Unicode strings
      ---------------
      Whether it is Qt4 or Qt5, the `translate` function
      always returns a unicode string.
      The difference is how it handles the input.
  
      Reference: https://pyside.github.io/docs/pyside/PySide/QtCore/
  
      In Qt4 the translate function has a 4th parameter to define the encoding
      of the input string.
  
      >>> QtCore.QCoreApplication.translate(context, text, None, UnicodeUT8)
      >>> QtGui.QApplication.translate(context, text, None, UnicodeUT8)
  
      Reference: https://doc.qt.io/qtforpython/PySide2/QtCore
  
      In Qt5 the strings are always assumed unicode, so the 4th parameter
      is for a different use, and it is not used.
  
      >>> QtCore.QCoreApplication.translate(context, text, None)
      >>> QtGui.QApplication.translate(context, text, None)
      """
      # Python 3 and Qt5
      # The text is a utf8 string, and since it is Qt5
      # the translate function doesn't use the 4th parameter
      if six.PY3:
          return Qtranslate(context, text, None)
      # Python 2
      elif QtCore.qVersion() > "4":
          # Python 2 and Qt5
          if utf8_decode:
              # The text is a utf8 string, and since it is Qt5
              # the translate function doesn't use the 4th parameter
              return Qtranslate(context, text, None)
          else:
              # The text is not a unicode string, and since it is Qt5
              # the translate function doesn't use the 4th parameter.
              # Therefore the output string needs to be encoded manually
              # as utf8 bytes before returning.
              return Qtranslate(context, text, None).encode("utf8")
      else:
          # Python 2 and Qt4
          if utf8_decode:
              # The text is a utf8 string, and since it is Qt4
              # the translate function uses the 4th parameter
              # to handle the input encoding.
              return Qtranslate(context, text, None, _encoding)
          else:
              # The text is not a unicode string, and since it is Qt4
              # the translate function uses the 4th parameter
              # to handle the encoding.
              # In this case, the `encoding` is `None`, therefore
              # the output string needs to be encoded manually
              # as utf8 bytes before returning.
              return Qtranslate(context, text, None, _encoding).encode("utf8")
function_tokens: def translate ( context , text , utf8_decode = False ) : # Python 3 and Qt5 # The text is a utf8 string, and since it is Qt5 # the translate function doesn't use the 4th parameter if six . PY3 : return Qtranslate ( context , text , None ) # Python 2 elif QtCore . qVersion ( ) > "4" : # Python 2 and Qt5 if utf8_decode : # The text is a utf8 string, and since it is Qt5 # the translate function doesn't use the 4th parameter return Qtranslate ( context , text , None ) else : # The text is not a unicode string, and since it is Qt5 # the translate function doesn't use the 4th parameter. # Therefore the output string needs to be encoded manually # as utf8 bytes before returning. return Qtranslate ( context , text , None ) . encode ( "utf8" ) else : # Python 2 and Qt4 if utf8_decode : # The text is a utf8 string, and since it is Qt4 # the translate function uses the 4th parameter # to handle the input encoding. return Qtranslate ( context , text , None , _encoding ) else : # The text is not a unicode string, and since it is Qt4 # the translate function uses the 4th parameter # to handle the encoding. # In this case, the `encoding` is `None`, therefore # the output string needs to be encoded manually # as utf8 bytes before returning. return Qtranslate ( context , text , None , _encoding ) . encode ( "utf8" )