Code Monkey home page Code Monkey logo

localer's Introduction

Gem Version Build Status

Localer is a tool that automatically detects missing I18n translations.

The goal is to preserve the integrity of translations. Localer parses and merges all application locales’ keys. At the next step, it searches for missing translations among the calculated keys.

Installation

Add this line to your application's Gemfile:

gem 'localer'

And then execute:

$ bundle

Or install it yourself as:

$ gem install localer

Usage

At the root directory of a Rails app, run:

$ localer check .

or for specific Rails path:

$ localer check /path/to/rails/application

CI integration

Localer is easy to integrate into your favorite CI workflow:

# .travis.yml

# other configuration options
script:
  - bundle exec bundle-audit
  - bundle exec rubocop
  - bundle exec rspec
  - bundle exec localer

or

# Rakefile

# other requirements
require 'localer/rake_task'
Localer::RakeTask.new()

task(:default).clear
task default: [:rubocop, :spec, :localer]

Support

Localer supports

  • Ruby: 2.4, 2.5, 2.6, 2.7
  • Rails: 5.0, 5.1, 5.2, 6.0, 6.1

Configuration

The behavior of Localer can be controlled via the .localer.yml configuration file. It makes it possible to disable locales and keys. The file can be placed in your project directory.

Disable specific locale

By default, Localer enables all locales, but you can disable it:

Locale:
  EN:
    Enabled: false

Exclude keys globally

By default, Localer enables all keys, but you can disable keys started with specified string or by regex:

Exclude:
  - /population\z/
  - .countries.france

Exclude keys for specific locale

Locale:
  EN:
    Exclude:
      - /population\z/
      - .countries.france

Using Rake

Localer ships with a rake task. To use Localer's rake task you simply need to require the task file and define a task with it. Below is a rake task that will run localer:

require 'rubygems'
require 'localer'
require 'localer/rake_task'

Localer::RakeTask.new(:localer)

When you now run:

$ rake -T

you should see

rake localer  # Run Localer

Development

After checking out the repo, run bundle exec appraisal install to install dependencies for each appraisal. Then, run bundle exec appraisal rake to run the tests.

Built With

  • Thor - Used for building command-line interfaces.
  • Appraisal - Used for testing against different versions of dependencies
  • Cucumber + Aruba - Used for testing command-line commands

Acknowledge

Special thanks to Roman Shamin for the logo.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/aderyabin/localer. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the Localer project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

localer's People

Contributors

aderyabin avatar alxygolubev avatar leoshaw avatar phoet 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  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

localer's Issues

"enable: false" does not works.

Hi, aderyabin.

I'm trying to disable some locales with .localer.yml.
BR, TR and AR are fine but zh-CN, zh-TW and de-CH does not works.

It seems that XX-YY locales does not works.
how do I disable it?

Thanks.

No Rails application found error

If I run localer check . or localer check ~/path it tells me that there is not rails app.
Poke around a little bit.

You have already activated thor 0.20.0, but your Gemfile requires thor 0.19.4. Prepending `bundle exec` to your command may solve this.

Don't know how to deal with bundler. It's not like a big deal. Just reporting, maybe someone will have the same problem.

NoMethodError: undefined method `fetch' for nil:NilClass

Good morning!
Exception NoMethodError raised after executing "bundle exec localer check ."

andrey@andrey-Vostro-3558:~/octoshell$ bundle exec localer check .  
bundler: failed to load command: localer (/home/andrey/.rbenv/versions/jruby-9.1.10.0/bin/localer)
NoMethodError: undefined method `fetch' for nil:NilClass
  /home/andrey/.rbenv/versions/jruby-9.1.10.0/lib/ruby/gems/shared/gems/localer-0.1.1/lib/localer/config.rb:24:in `load'
  /home/andrey/.rbenv/versions/jruby-9.1.10.0/lib/ruby/gems/shared/gems/localer-0.1.1/lib/localer.rb:23:in `configure'
  /home/andrey/.rbenv/versions/jruby-9.1.10.0/lib/ruby/gems/shared/gems/localer-0.1.1/bin/localer:16:in `check'
  /home/andrey/.rbenv/versions/jruby-9.1.10.0/lib/ruby/gems/shared/gems/thor-0.20.0/lib/thor/command.rb:27:in `run'
  /home/andrey/.rbenv/versions/jruby-9.1.10.0/lib/ruby/gems/shared/gems/thor-0.20.0/lib/thor/invocation.rb:126:in `invoke_command'
  /home/andrey/.rbenv/versions/jruby-9.1.10.0/lib/ruby/gems/shared/gems/thor-0.20.0/lib/thor.rb:387:in `dispatch'
  /home/andrey/.rbenv/versions/jruby-9.1.10.0/lib/ruby/gems/shared/gems/thor-0.20.0/lib/thor/base.rb:466:in `start'
  /home/andrey/.rbenv/versions/jruby-9.1.10.0/lib/ruby/gems/shared/gems/localer-0.1.1/bin/localer:46:in `<main>'
  org/jruby/RubyKernel.java:979:in `load'
  /home/andrey/.rbenv/versions/jruby-9.1.10.0/bin/localer:1:in `<main>'
  org/jruby/RubyKernel.java:979:in `load'
  /home/andrey/.rbenv/versions/jruby-9.1.10.0/bin/localer:22:in `(root)'

Wrong pluralization handling

In some languages a word needs pluralization, but may be not in another.

Considering this translations from the rails-i18n gem:

en:
  number:
    human:
      decimal_units:
        units:
          billion: Billion

and

de:
  number:
    human:
      decimal_units:
        units:
          billion:
            one: Milliarde
            other: Milliarden

results in a localer error:

Missing translations found (...):
* de.number.human.decimal_units.units.billion
* en.number.human.decimal_units.units.billion.one
* en.number.human.decimal_units.units.billion.other

Any plans to support this?

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.