Freeseer / freeseer

Designed for capturing presentations at conferences. Pre-fill a list of talks to record, record them, and upload them to YouTube with our YouTube Uploader.
http://freeseer.readthedocs.org
GNU General Public License v3.0
215 stars 110 forks source link

Error happens when transfer to a unicode language #584

Closed Cryspia closed 9 years ago

Cryspia commented 9 years ago

When chooses Japanese, Simplified Chinese or Traditional Chinese in the Language menu, there will be an error logged in the terminal:

Traceback (most recent call last):
  File "freeseer\frontend\qtcommon\FreeseerApp.py", line 146, in translate
    self.retranslate()
  File "freeseer\frontend\record\record.py", line 227, in retranslate
    self.idleString))
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-1: ordinal not in range(128)

The problem is caused by not using unicode for .format:

            self.mainWidget.statusLabel.setText("{} {} --- {} ".format(self.freeSpaceString,
                                                                       get_free_space(self.config.videodir),
                                                                       self.idleString))

should be

            self.mainWidget.statusLabel.setText(u"{} {} --- {} ".format(self.freeSpaceString,
                                                                       get_free_space(self.config.videodir),
                                                                       self.idleString))

There are several places with the same problem in record.py

dideler commented 9 years ago

This fix will only work on certain versions of Python (which is fine for now, but creates an extra task if we ever support a version between 2.7 and 3.3).

Would it be better to use a suggestion from https://docs.python.org/2/howto/pyporting.html#from-future-import-unicode-literals?

mtomwing commented 9 years ago

IMO u'foobar' is fine because Python 3.4 is already the latest stable 3+ version and there would be no reason for a distro to ship anything lower once they make the transition to 3.

dideler commented 9 years ago

If we can port immediately to 3.4 or higher, then we're good. I'll go ahead and merge #585.

dideler commented 9 years ago

Issue still present for the avWidget (config tool). The PR only had fixes for mainWidget.

Traceback (most recent call last):
  File "/home/dennis/github/Freeseer/freeseer/src/freeseer/frontend/qtcommon/FreeseerApp.py", line 146, in translate
    self.retranslate()
  File "/home/dennis/github/Freeseer/freeseer/src/freeseer/frontend/configtool/configtool.py", line 219, in retranslate
    self.avWidget.fileDirPushButton.setText("{}...".format(self.app.translate("ConfigToolApp", "Browse")))
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-1: ordinal not in range(128)
Cryspia commented 9 years ago

OK. I will also fix this one in this week.