Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for localising regexps #18

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Conversation

kulpreet
Copy link

I needed to parse out emails for Italian users. All my users are Italian.

The regexps were all in English. I needed to support Italian regular expressions.

So I made some changes, which hopefully will allow other contributors to provide regular expressions in other languages.

Changes include:

  1. Move the constant regular expressions from EmailReplyParser class to a locales.yaml file
  2. Allow selection of locales while calling EmailReplyParser.read and EmailReplyParser.parse_reply
  3. The default locale is 'en'
  4. Add tests for the Italian locale by adding copies of emails into 'it' folder.

Dependency added

  1. Need to use pyyaml to parse the locales.yaml. So added that to setup.py as a requires and tests_requireoption.

Possible Improvements

  1. There probably is a better way to handle locales.yaml in setup using package_data. I am new to Python, so didn't make much progress on it. But if someone can advise me what is the best approach to allow setup/install/runtime selection of configuration options - I am happy to make those changes.

Add the first locale, IT, that we care for right now

Needed improvements include a better way to package the local regular expressions
Add the first locale, IT, that we care for right now

Needed improvements include a better way to package the local regular expressions
    - Is this what travis is really complaining about?

Fix _test_test file name error for italian test
@roycehaynes
Copy link
Contributor

@kulpreet I like this configuration approach towards language specific regex. Going to take a closer look, resolve some issues, and get @kageurufu thoughts.

@kageurufu
Copy link
Contributor

I like the idea of this, although I would prefer to store the localized regex in something readable through the standard library instead of bringing in an extra dependency just to read YAML files. Perhaps even just have a python module and dicts or similar.

kageurufu added a commit that referenced this pull request Sep 22, 2016
Based on PR #18, modified to no longer require pyyaml

This keeps email_reply_parser stdlib only, and allows easy addition
 of new locales without needing to parse config files
@Shane-EdgeTier
Copy link

This looks great - is this library still maintained? It would be great to get language support in here.

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.

4 participants