cirandas.net

ref: master

test/unit/i18n_test.rb


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
require_relative "../test_helper"

class I18nTest < ActiveSupport::TestCase

  # XXX this duplicates the list from lib/tasks/gettext.rake
  files_to_translate = [
    '{app,lib}/**/*.{rb,rhtml,erb}',
    'config/initializers/*.rb',
    'public/*.html.erb',
    'public/designs/themes/{base,noosfero,profile-base}/*.{rhtml,html.erb}',
  ].flat_map{ |pattern| Dir[pattern] }

  plugins_files_to_translate = Dir.glob("plugins/**/*.{rb,html.erb}")

  (files_to_translate + plugins_files_to_translate).each do |f|
    test "translation marks in #{f}" do
      next unless File.exist? f
      lines = File.readlines(f).select do |line|
        line =~ /\b_\(["'][^)]*#\{/
      end
      assert lines == [], "found interpolation in translatable strings:\n" + lines.join("\n")
    end
  end

end