Skip to content

Instantly share code, notes, and snippets.

@ixtli
Created March 6, 2013 16:10
Show Gist options
  • Save ixtli/5100433 to your computer and use it in GitHub Desktop.
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.
#!/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