Commit Graph

12 Commits

Author SHA1 Message Date
Javi Martín
65c9786db7 Apply Layout/RedundantLineBreak rule to short lines
We're not adding the rule because it would apply the current line length
rule of 110 characters per line. We still haven't decided whether we'll
keep that rule or make lines shorter so they're easier to read,
particularly when vertically splitting the editor window.

So, for now, I'm applying the rule to lines which are about 90
characters long.
2021-09-03 11:49:53 +02:00
Javi Martín
5b6dc9d7ff Fix enforce_available_locales leak between tests
Even if it doesn't seem to have consequences right now, we certainly
prefer other tests to use the default value.
2021-09-03 11:49:52 +02:00
Javi Martín
071bcb7023 Add and apply Rails/I18nLocaleAssignment rule
This rule was added in rubocop-rails 2.11.0.

Although we prevent I18n locale leaking between tests by setting it
before each test, the `with_locale` method makes the scope of the locale
change more obvious.
2021-09-03 11:49:52 +02:00
Javi Martín
57ef380379 Add and apply Layout/ExtraSpacing rubocop rule 2019-10-24 18:11:58 +02:00
Javi Martín
db97f9d08c Add and apply rubocop rules for empty lines
We were very inconsistent regarding these rules.

Personally I prefer no empty lines around blocks, clases, etc... as
recommended by the Ruby style guide [1], and they're the default values
in rubocop, so those are the settings I'm applying.

The exception is the `private` access modifier, since we were leaving
empty lines around it most of the time. That's the default rubocop rule
as well. Personally I don't have a strong preference about this one.


[1] https://rubystyle.guide/#empty-lines-around-bodies
2019-10-24 17:11:47 +02:00
Javi Martín
f9ed186909 Add rubocop spacing rules
We were following these rules in most places; we just didn't define them
anywhere.
2019-09-10 21:04:56 +02:00
Julian Nicolas Herrero
d821848add Merge pull request #3307 from consul/return_string_in_method_pluralize
[Backport] Return a String in I18n method 'pluralize'
2019-02-18 15:25:40 +01:00
Julian Herrero
366505f886 Return a String in I18n method 'pluralize'
If a translation was missing returning a Fixnum was raising an
exception 'undefined method X for Fixnum'.
2019-02-15 11:59:57 +01:00
Julian Herrero
31ac8b7f55 Change single quotes to double quotes 2019-02-15 11:40:39 +01:00
voodoorai2000
3976b2f4f2 Fix pluralization spec when using different default locale
This spec was failing due to using :es as the default_locale in application.rb[1], but using :en as the default_locale in the test environment[2]

The fallback rules where getting a little confused and not including the default locale, for the test environment, in the fallback rules

With this commit we are making sure that rule is created, as it would in a production environment that uses the default_locale in application.rb

[1] https://github.com/AyuntamientoMadrid/consul/blob/master/config/application.rb#L22

[2] https://github.com/AyuntamientoMadrid/consul/blob/master/spec/rails_helper.rb#L15
2018-10-17 13:26:47 +02:00
voodoorai2000
be80973e44 Avoid InvalidPluralizationData exception when missing translations
We work with many languages using Crowdin[1]

Sometimes translators forget to fill in all the necessary plural forms of a translation (zero, one, other) and in those cases we were seing the exception InvalidPluralizationData being raised

There are a number of approches to fix this... from being more strict when approving translations, to automatically extrapolating what those plural forms should be

For now, we've gone for a simple approach to display the actual count(0,1,2,3,4, etc) instead of the whole translation

So, if the plural form of "1 comment" is missing, just a "1" will be displayed and no exceptions raised

Note: The first two specs, test what is really Rails' functionalities. However as we are monkey patching the pluralize method, I thought it was appropriate to doble check it

[1]https://crowdin.com/project/consul
2018-10-05 12:26:07 +02:00
kikito
b1acbeb39d Adds i18n-tasks 2015-08-06 18:31:26 +02:00