Created
March 6, 2013 16:10
-
-
Save ixtli/5100433 to your computer and use it in GitHub Desktop.
print out currency prefixes for all utf8 locales on the current POSIX compliant machine. requires python 2.7 (for the subprocess module). change utfLocaleSuffix to match the utf8 extension for locale names on your machine. you can determine this by running `locale -a | grep 'utf'` and seeing what they look like.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# coding: utf-8 | |
import locale, subprocess; | |
# on centos this is 'utf8' | |
utfLocaleSuffix = 'UTF-8'; #darwin/freebsd | |
def main(): | |
# get all locales | |
locales = subprocess.check_output(['locale', '-a']).split('\n'); | |
out = ""; | |
for l in locales: | |
if l.split('.')[-1] != utfLocaleSuffix: | |
continue; | |
locale.setlocale(locale.LC_ALL, l); | |
conv = locale.localeconv(); | |
out = out + " " + '{currency_symbol}'.format(**conv); | |
print out; | |
if __name__ == "__main__": | |
main(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment