GithubHelp home page GithubHelp logo

pyseeyou's People

Contributors

aenterprise avatar brawaru avatar jamesdommisse avatar konysko avatar lukasz-madon avatar siame avatar tabulatejarl8 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pyseeyou's Issues

[bug] Passing in options not in the list should fallback to 'other' while the library just crash

from pyseeyou import format

result = format('''{GENDER, select,
                       male {He}
                     female {She}
                      other {They}
                   } found {NUM_RESULTS, plural,
                       one {1 result}
                     other {# results}
                   } in {NUM_CATEGORIES, plural,
                         one {1 category}
                       other {# categories}
                   }.''',
        {'GENDER': 'male', 'NUM_RESULTS': 1, 'NUM_CATEGORIES': '2'}, 'en')

=> u'He found 1 result in 2 categories.'

In the readme the above example was given, a minimum example to recreate the problem is to pass

{'GENDER': 'non_binary', 'NUM_RESULTS': 1, 'NUM_CATEGORIES': '2'}, 'en')

non_binary is not in [male, female] so it should fallback to other

The problem is this line https://github.com/rolepoint/pyseeyou/blob/master/pyseeyou/node_visitor.py#L136 doesnt actually check if self.options[key] exist in item

so it need to be changed from

        if key in self.options:
            return item[self.options[key]]

to something like

        if key in self.options:
            item_key = self.options[key]
            if item_key:
                return item[self.options[key]]
            else:
                return item['other']

locale support for spanish

Hi,
I saw in locale.py pyseeyou does not support Spanish. Is there a plan to add support for Spanish(es)?

thanks

Python 3.6 - DeprecationWarning: invalid escape sequence

When running pytest, I see the following:

pyseeyou/grammar.py:34
  github/pyseeyou/pyseeyou/grammar.py:34: DeprecationWarning: invalid escape sequence \w
    ''')

<unknown>:1
  <unknown>:1: DeprecationWarning: invalid escape sequence \w
  <unknown>:1: DeprecationWarning: invalid escape sequence \w
  <unknown>:1: DeprecationWarning: invalid escape sequence \w
  <unknown>:1: DeprecationWarning: invalid escape sequence \.
  <unknown>:1: DeprecationWarning: invalid escape sequence \s

This warning came about because of https://bugs.python.org/issue27364

escape sequences for message syntax are throwing an error

File "/../my_file.py", line 103, in _process_message
return format(actual_message, processed_params, _get_message_format_locale(locale_code))
File "/.../lib/python2.7/site-packages/pyseeyou/init.py", line 13, in format
ast = ICUMessageFormat.parse(msg)
File "/.../lib/python2.7/site-packages/parsimonious/grammar.py", line 115, in parse
return self.default_rule.parse(text, pos=pos)
File "/.../lib/python2.7/site-packages/parsimonious/expressions.py", line 122, in parse
raise IncompleteParseError(text, node.end, self)
IncompleteParseError: Rule 'message_format_pattern' matched in its entirety, but it didn't consume all the text. The non-matching portion of the text begins with '{n,}: in regular ex' (line 1, column 14).

String example: "Disallowed: \\{n,\\}: in regular expression"

This should be supported as described here:

Supports escape sequences for message syntax chars, e.g.: "\{foo\}" will output: "{foo}" in the formatted output instead of interpreting it as a foo argument.

Auto-generate locale pluralisation functions

The CLDR provides an XML file (current version can be found in the most recent vXX ZIP downloaded from here: http://cldr.unicode.org/index/downloads, navigate to core/supplemental/plurals.xml) listing each of the locales and their respective plurality rules.

This file is structured so that languages with equivalent rules are even grouped together. The plurality rules are even formatted in accordance with an expression language, which could be used to parse them quite easily.

This means that we can much more effectively generate the plurality functions from this file, rather than type them all out by hand in locales.py and store/update them as and when/if they change.

Ideally this would be a script that generates a working locales.py file post/during pip-install, and automatically pulls down and uses the latest CLDR plurals.xml file as a base.

Python 3 compatibility

Need reworking of the usage of the unicode keyword around the codebase, meaning that the library is not currently Python 3 compatible.

Add a license

I can't find a license for this library. It would be great to add one so people know if it's freely useable.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.