Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3.  
  4. import os
  5. from gettext import *
  6. _ = gettext
  7.  
  8. # Returns a dictionary with the xdg dirs for that user,
  9. # or the default xdg dirs based on the current language,
  10. # if that user's xdg dirs aren't set.
  11. # Raises an error if the user doesn't exist.
  12. def get_xdg_dirs(user, lang=""):
  13. if lang:
  14. oldlang = os.environ['LANG']
  15. os.environ["LANG"] = lang
  16. bindtextdomain("xdg-user-dirs")
  17. textdomain("xdg-user-dirs")
  18. result = {
  19. 'Desktop': _('Desktop'),
  20. 'Downloads': _('Downloads'),
  21. 'Applications': _('Applications'),
  22. 'Documents': _('Documents'),
  23. 'Download': _('Download'),
  24. 'Movies': _('Movies'),
  25. 'Music': _('Music'),
  26. 'Photos': _('Photos'),
  27. 'Pictures': _('Pictures'),
  28. 'Projects': _('Projects'),
  29. 'Public': _('Public'),
  30. 'Share': _('Share'),
  31. 'Templates': _('Templates'),
  32. 'Videos': _('Videos')
  33. }
  34. if lang:
  35. os.environ['LANG'] = oldlang
  36. return result
  37.  
  38. for lang in ('el', 'ru'):
  39. print "==== Language=%s ====" % lang
  40. for k, v in get_xdg_dirs("alkisg", lang).iteritems():
  41. print "%s=%s" % (k, v)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement