X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/30a01fb7f9dedc757a27f9bf97e3d720f4530508..d58cae6ff68c54cba21d46c44d03e95589adf301:/test/lib/i18n_test.rb diff --git a/test/lib/i18n_test.rb b/test/lib/i18n_test.rb index 3f46955b3..def2442bf 100644 --- a/test/lib/i18n_test.rb +++ b/test/lib/i18n_test.rb @@ -69,6 +69,15 @@ class I18nTest < ActiveSupport::TestCase end end + # We should avoid using the key `zero:` in English, since that key + # is used for "numbers ending in zero" in other languages. + def test_en_for_zero_key + en = YAML.load_file(Rails.root.join("config/locales/en.yml")) + assert_nothing_raised do + check_keys_for_zero(en) + end + end + private def translation_keys(scope = nil) @@ -116,4 +125,14 @@ class I18nTest < ActiveSupport::TestCase end end end + + def check_keys_for_zero(hash) + hash.each_pair do |k, v| + if v.is_a? Hash + check_keys_for_zero(v) + else + raise "Avoid using 'zero' key in '#{k}: #{v}'" if k.to_s == "zero" + end + end + end end