Skip to content

Conversation

@urosevic
Copy link
Contributor

As reported on ST forum topic SideBar Enhanc.. (Clipboard, Open With., Reload renamed) I experienced issue with Serbian Cyrillic locale on Windows 10 - weekday and month name has been printed as question marks instead readable Cyrillic text in ST status-bar.

After some research, I decided to add new option to override default system locale in SideBarEnhancements option to print modified time in status-bar.

So, this pull-request adds support for custom locale of date/time with option 'statusbar_modified_time_locale'

Example for user's settings SideBar.sublime-settings file:

{ "statusbar_modified_time_locale": "Serbian (Latin)_Serbia", }

Cheers

titoBouzout added a commit that referenced this pull request Oct 11, 2015
Add support for custom locale in modified time
@titoBouzout titoBouzout merged commit 468be50 into titoBouzout:st3 Oct 11, 2015
@titoBouzout
Copy link
Owner

Hi! Thanks a lot, I'm gonna change it a bit but thank you for your reporting, investigation and fix of the issue

@titoBouzout
Copy link
Owner

Thanks for fixing the version number that was on my todo list. I changed the way is decode, because I dont want to alter the global locale. Can you please confirm still works by setting Serbian (Latin)_Serbia? Thanks!

@titoBouzout
Copy link
Owner

I believe the real problem here is this bug http://bugs.python.org/issue8304

Maybe this just works?
import time; sublime.active_window().active_view().set_status('test', time.strftime("%A %b %d %H:%M:%S %Y").decode('utf-8'));

@urosevic
Copy link
Contributor Author

Unfortunately for me .decode() does not work:

>>> import time; sublime.active_window().active_view().set_status('test', time.strftime("%A %b %d %H:%M:%S %Y").decode('utf-8'));
Traceback (most recent call last):
  File "<string>", line 1, in <module>
AttributeError: 'str' object has no attribute 'decode'

That is because string is already decoded but as Windows 1251 in case of locale 'Serbian (Cyrillic)_Serbia.1251'.

Your latest changes in code does not produce any output to statusbar (because decode() does not work).

Solution with overriding system locale with:

{ "statusbar_modified_time_locale": "Serbian (Latin)_Serbia", }

work because then I'm getting weekday and month name in Serbian Latin script (encoding Windows 1250), or I even can use C locale instead localized date/time.

Hope this will help you to track down this tiny boring issue :)

@titoBouzout
Copy link
Owner

okei, what I want to avoid is to change the global locale, I just want the string in unicode. Maybe with this:

import time; sublime.active_window().active_view().set_status('test', time.strftime("%A %b %d %H:%M:%S %Y").encode('1251').decode('utf8'));

I think we should be able to change the encoding of the string that time.strftime outputs (if its not broken)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants