Coder Social home page Coder Social logo

syeopite / lens Goto Github PK

View Code? Open in Web Editor NEW
16.0 16.0 1.0 1.51 MB

A multiformat internationalization (i18n) shard for Crystal.

License: MIT License

Crystal 100.00%
crystal gettext hacktoberfest i18n internationalization l10n l18n language locale localization translation

lens's People

Contributors

syeopite avatar

Stargazers

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

Watchers

 avatar  avatar

lens's Issues

[Enhancement] Provide API to configure behaviors of different backends

In Lens, each of the backends currently have a slightly different behavior.

For instance, the Gettext family of backends returns the given ID when a translation is not found.

backend = Gettext::MOBackend.new("locales")
catalogue_hash = backend.create()
catalogue = catalogue_hash["en_US"]
catalogue.gettext("I don't exist") # => "I don't exist" 

Whereas the RubyI18n YAML backend would raise an LensExceptions::MissingTranslation

catalogue = RubyI18n::Yaml.new("locales")
catalogue.translate("en", "I  also don't exist") # => LensExceptions::MissingTranslation

Not to mention the fact that Gettext requires creating a catalogue object first while the other doesn't.

This discrepancy is intentional, in order to preserve the behaviors seen in their reference or intended implementations.

However, I do see merit in a potential way to configure these behaviors. It wouldn't change the API differences, but it would help resolve any unintended errors a developer might experience when swapping backends.

Finish implementation of CLDR number formatting

The basic infrastructure for implementing number formatting was introduced in Lens with commit 5997047. Since then, almost all features needed to format a number has been added. In fact, the formatter is actually present and working:

In commit 7e2d9f1 of master, this code produces the expected output of 10,00,00,000.124

rules, metadata = CLDR::Numbers::PatternParser.new("#,##0.##").parse
formatter = CLDR::Numbers::PatternFormatter(CLDR::Languages::EN).new(rules, metadata)

formatter.format(1000.129) # => 1,000.13
formatter.format(-1000.129) # => -1,000.13

However, despite all this there's still quite a few crucial features missing.

  • Explicit plus signs and negative patterns
  • Prefixes
  • Suffixes
  • Minimum grouping digits
  • Significant digits
  • Scientific notations
  • Rounding
  • Padding
  • Currency symbols
  • Fractional grouping

A better public API should then be constructed before we can push it out to version 0.2.

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.