Git Product home page Git Product logo

babilu's People

Contributors

mvanholstyn avatar romanbsd avatar toretore avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar

babilu's Issues

rails 3 compatibility

To make babilu compatible with rails 3 I18n interpolation syntax (e.g. ' you have %{amount} unread messages' (rather than the {{amount}} syntax)) I've changed the interpolatePattern in the top of babilu.js to:
var interpolatePattern = /%{([^}]+)}/g;

Maybe the interpolate regexp can be adjusted when generating locales.js based on the existence/value of RAILS_GEM_VERSION ?

Fix Railtie

In some configurations "rails server" refuses to start with: "/Users/nkuebler/projects/viewr/vendor/plugins/babilu/lib/babilu.rb:51:in `block in class:Railtie': You have a nil object when you didn't expect it! (NoMethodError)"

A possible fix is to change 'balibu.rb' from

 class Railtie < Rails::Railtie
    config.before_configuration do
      config.action_view.javascript_expansions[:defaults] ||= [] << 'locales'
    end
  end if defined?(Rails::Railtie)

to

 class Railtie < Rails::Railtie
    config.before_configuration do
      config.action_view.javascript_expansions ||= {}
      config.action_view.javascript_expansions[:defaults] ||= [] << 'locales'
    end
  end if defined?(Rails::Railtie)

Rails 3.1 assets support

It would be nice if the gem was updated to generated the locales.js file in vendor/assets/javascripts/locales.js. Perhaps even better would be to make the path configurable but at least having it in a loaded directory would fix issues in 3.1

translation with count option (pluralize) fails when count == 0

example:
in en.yml:
items_left:
one: '1 item left'
other: '{{count}} items left'

I18n.t('items_left', {'count': 0}) returns [Object Object] rather than the expected '0 items left'
This error is caused by the first line in the pluralize function:

I18n.pluralize = function(value, count){
  if (!count) return value;
  return count == 1 ? value.one : value.other;
};

The (!count) expression returns false when count is 0, causing the value object to be returned without choosing the correct plural form. The value object is an object containing the 'one' and 'other' keys, it doesn't really make sense to return it. In my opinion this if (!count) check can be safely removed, and the function changed to this:

I18n.pluralize = function(value, count){
  return (typeof(count) !== 'undefined' && count == 1) ? value.one : value.other;
}

This way pluralize always returns a correct key.

locales.js generating multiple times in development environment causes javascript parse error

After struggling with a JavaScript parse error in locales.js for quite a while, I determined the cause. The error is a missing } even though the code looks/lints fine. It is a result of multiple near-simultaneous requests in development mode.

We have a route to a stylesheet action that pulls the CSS from a database. When a page is hit (in development), the generate_locale_javascript filter is fired once for the page and again when the page loads the stylesheet action. My assumption is that this results in a partially overwritten locales.js being returned, hence the parse error.

My solution for now is as follows:
skip_after_filter :generate_locale_javascript, :only => :stylesheet

I'm submitting this so others are aware of the issue, and perhaps we can come up with a better solution in Babilu itself. Regenerating only if the yml files change should at least reduce, if not eliminate the issues.

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.