Skip to content

Instantly share code, notes, and snippets.

@ojii
Created March 30, 2011 09:16
Show Gist options
  • Select an option

  • Save ojii/894111 to your computer and use it in GitHub Desktop.

Select an option

Save ojii/894111 to your computer and use it in GitHub Desktop.
A script that translates any language into French!
#!/usr/bin/python
# -*- coding: utf-8 -*-
import argparse
import random
mappings = {
'a': [u'à', u'â'],
'c': [u'ç'],
'e': [u'é', u'è', u'ê'],
}
def _frenchify_single(bit, i):
if bit not in mappings:
return bit
choices = [bit]
for x in range(i):
choices += mappings[bit]
return random.choice(choices)
def frenchify(value, i):
return ''.join([_frenchify_single(bit, i) for bit in value])
def main():
parser = argparse.ArgumentParser()
parser.add_argument('-i', default=1, type=int)
parser.add_argument('data')
namespace = parser.parse_args()
print frenchify(namespace.data, namespace.i)
if __name__ == '__main__':
main()
@ojii

ojii commented Mar 30, 2011

Copy link
Copy Markdown
Author

but of çoursé!

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