Revision 1297:0a574315af3e .svn/pristine/d3

View differences:

.svn/pristine/d3/d39d55792569592e631ccb43cfe454592c67567f.svn-base
1
desc 'Updates and checks locales against en.yml'
2
task :locales do
3
  %w(locales:update locales:check_interpolation).collect do |task|
4
    Rake::Task[task].invoke
5
  end
6
end
7

  
8
namespace :locales do
9
  desc 'Updates language files based on en.yml content (only works for new top level keys).'
10
  task :update do
11
    dir = ENV['DIR'] || './config/locales'
12

  
13
    en_strings = YAML.load(File.read(File.join(dir,'en.yml')))['en']
14

  
15
    files = Dir.glob(File.join(dir,'*.{yaml,yml}'))
16
    files.sort.each do |file|
17
      puts "Updating file #{file}"
18
      file_strings = YAML.load(File.read(file))
19
      file_strings = file_strings[file_strings.keys.first]
20

  
21
      missing_keys = en_strings.keys - file_strings.keys
22
      next if missing_keys.empty?
23

  
24
      puts "==> Missing #{missing_keys.size} keys (#{missing_keys.join(', ')})"
25
      lang = File.open(file, 'a')
26

  
27
      missing_keys.each do |key|
28
        {key => en_strings[key]}.to_yaml.each_line do |line|
29
          next if line =~ /^---/ || line.empty?
30
          puts "  #{line}"
31
          lang << "  #{line}"
32
        end
33
      end
34

  
35
      lang.close
36
    end
37
  end
38

  
39
  desc 'Checks interpolation arguments in locals against en.yml'
40
  task :check_interpolation do
41
    dir = ENV['DIR'] || './config/locales'
42
    en_strings = YAML.load(File.read(File.join(dir,'en.yml')))['en']
43
    files = Dir.glob(File.join(dir,'*.{yaml,yml}'))
44
    files.sort.each do |file|
45
      puts "parsing #{file}..."
46
      file_strings = YAML.load(File.read(file))
47
      file_strings = file_strings[file_strings.keys.first]
48

  
49
      file_strings.each do |key, string|
50
        next unless string.is_a?(String)
51
        string.scan /%\{\w+\}/ do |match|
52
          unless en_strings[key].nil? || en_strings[key].include?(match)
53
            puts "#{file}: #{key} uses #{match} not found in en.yml"
54
          end
55
        end
56
      end
57
    end
58
  end
59

  
60
  desc <<-END_DESC
61
Removes a translation string from all locale file (only works for top-level childless non-multiline keys, probably doesn\'t work on windows).
62

  
63
This task does not work on Ruby 1.8.6.
64
You need to use Ruby 1.8.7 or later.
65

  
66
Options:
67
  key=key_1,key_2    Comma-separated list of keys to delete
68
  skip=en,de         Comma-separated list of locale files to ignore (filename without extension)
69
END_DESC
70

  
71
  task :remove_key do
72
    dir = ENV['DIR'] || './config/locales'
73
    files = Dir.glob(File.join(dir,'*.yml'))
74
    skips = ENV['skip'] ? Regexp.union(ENV['skip'].split(',')) : nil
75
    deletes = ENV['key'] ? Regexp.union(ENV['key'].split(',')) : nil
76
    # Ignore multiline keys (begin with | or >) and keys with children (nothing meaningful after :)
77
    delete_regex = /\A  #{deletes}: +[^\|>\s#].*\z/
78

  
79
    files.each do |path|
80
      # Skip certain locales
81
      (puts "Skipping #{path}"; next) if File.basename(path, ".yml") =~ skips
82
      puts "Deleting selected keys from #{path}"
83
      orig_content = File.open(path, 'r') {|file| file.read}
84
      File.open(path, 'w') {|file| orig_content.each_line {|line| file.puts line unless line.chomp =~ delete_regex}}
85
    end
86
  end
87

  
88
  desc <<-END_DESC
89
Adds a new top-level translation string to all locale file (only works for childless keys, probably doesn\'t work on windows, doesn't check for duplicates).
90

  
91
Options:
92
  key="some_key=foo"
93
  key1="another_key=bar"
94
  key_fb="foo=bar"         Keys to add in the form key=value, every option of the form key[,\\d,_*] will be recognised
95
  skip=en,de               Comma-separated list of locale files to ignore (filename without extension)
96
END_DESC
97

  
98
  task :add_key do
99
    dir = ENV['DIR'] || './config/locales'
100
    files = Dir.glob(File.join(dir,'*.yml'))
101
    skips = ENV['skip'] ? Regexp.union(ENV['skip'].split(',')) : nil
102
    keys_regex = /\Akey(\d+|_.+)?\z/
103
    adds = ENV.reject {|k,v| !(k =~ keys_regex)}.values.collect {|v| Array.new v.split("=",2)}
104
    key_list = adds.collect {|v| v[0]}.join(", ")
105

  
106
    files.each do |path|
107
      # Skip certain locales
108
      (puts "Skipping #{path}"; next) if File.basename(path, ".yml") =~ skips
109
      # TODO: Check for dupliate/existing keys
110
      puts "Adding #{key_list} to #{path}"
111
      File.open(path, 'a') do |file|
112
        adds.each do |kv|
113
          Hash[*kv].to_yaml.each_line do |line|
114
            file.puts "  #{line}" unless (line =~ /^---/ || line.empty?)
115
          end
116
        end
117
      end
118
    end
119
  end
120

  
121
  desc 'Duplicates a key. Exemple rake locales:dup key=foo new_key=bar'
122
  task :dup do
123
    dir = ENV['DIR'] || './config/locales'
124
    files = Dir.glob(File.join(dir,'*.yml'))
125
    skips = ENV['skip'] ? Regexp.union(ENV['skip'].split(',')) : nil
126
    key = ENV['key']
127
    new_key = ENV['new_key']
128
    abort "Missing key argument" if key.blank?
129
    abort "Missing new_key argument" if new_key.blank?
130

  
131
    files.each do |path|
132
      # Skip certain locales
133
      (puts "Skipping #{path}"; next) if File.basename(path, ".yml") =~ skips
134
      puts "Adding #{new_key} to #{path}"
135

  
136
      strings = File.read(path)
137
      unless strings =~ /^(  #{key}: .+)$/
138
        puts "Key not found in #{path}"
139
        next
140
      end
141
      line = $1
142

  
143
      File.open(path, 'a') do |file|
144
        file.puts(line.sub(key, new_key))
145
      end
146
    end
147
  end
148

  
149
  desc 'Check parsing yaml by psych library on Ruby 1.9.'
150

  
151
  # On Fedora 12 and 13, if libyaml-devel is available,
152
  # in case of installing by rvm,
153
  # Ruby 1.9 default yaml library is psych.
154

  
155
  task :check_parsing_by_psych do
156
    begin
157
      require 'psych'
158
      parser = Psych::Parser.new
159
      dir = ENV['DIR'] || './config/locales'
160
      files = Dir.glob(File.join(dir,'*.yml'))
161
      files.sort.each do |filename|
162
        next if File.directory? filename
163
        puts "parsing #{filename}..."
164
        begin
165
          parser.parse File.open(filename)
166
        rescue Exception => e1
167
          puts(e1.message)
168
          puts("")
169
        end
170
      end
171
    rescue Exception => e
172
      puts(e.message)
173
    end
174
  end
175
end
.svn/pristine/d3/d3b7ec6980c63f6b117346516bdccd11679e27f3.svn-base
1
<%= error_messages_for 'project' %>
2

  
3
<div class="box tabular">
4
<!--[form:project]-->
5
<p><%= f.text_field :name, :required => true, :size => 60 %></p>
6

  
7
<% unless @project.allowed_parents.compact.empty? %>
8
    <p><%= label(:project, :parent_id, l(:field_parent)) %><%= parent_project_select_tag(@project) %></p>
9
<% end %>
10

  
11
<p><%= f.text_area :description, :rows => 5, :class => 'wiki-edit' %></p>
12
<p><%= f.text_field :identifier, :required => true, :size => 60, :disabled => @project.identifier_frozen? %>
13
<% unless @project.identifier_frozen? %>
14
  <em class="info"><%= l(:text_length_between, :min => 1, :max => Project::IDENTIFIER_MAX_LENGTH) %> <%= l(:text_project_identifier_info).html_safe %></em>
15
<% end %></p>
16
<p><%= f.text_field :homepage, :size => 60 %></p>
17
<p><%= f.check_box :is_public %></p>
18
<%= wikitoolbar_for 'project_description' %>
19

  
20
<% @project.custom_field_values.each do |value| %>
21
  <p><%= custom_field_tag_with_label :project, value %></p>
22
<% end %>
23
<%= call_hook(:view_projects_form, :project => @project, :form => f) %>
24
</div>
25

  
26
<% if @project.new_record? %>
27
<fieldset class="box tabular"><legend><%= l(:label_module_plural) %></legend>
28
<% Redmine::AccessControl.available_project_modules.each do |m| %>
29
    <label class="floating">
30
    <%= check_box_tag 'project[enabled_module_names][]', m, @project.module_enabled?(m), :id => "project_enabled_module_names_#{m}" %>
31
    <%= l_or_humanize(m, :prefix => "project_module_") %>
32
    </label>
33
<% end %>
34
<%= hidden_field_tag 'project[enabled_module_names][]', '' %>
35
<%= javascript_tag 'observeProjectModules()' %>
36
</fieldset>
37
<% end %>
38

  
39
<% if @project.new_record? || @project.module_enabled?('issue_tracking') %>
40
<% unless @trackers.empty? %>
41
<fieldset class="box tabular" id="project_trackers"><legend><%=l(:label_tracker_plural)%></legend>
42
<% @trackers.each do |tracker| %>
43
    <label class="floating">
44
    <%= check_box_tag 'project[tracker_ids][]', tracker.id, @project.trackers.include?(tracker) %>
45
    <%=h tracker %>
46
    </label>
47
<% end %>
48
<%= hidden_field_tag 'project[tracker_ids][]', '' %>
49
</fieldset>
50
<% end %>
51

  
52
<% unless @issue_custom_fields.empty? %>
53
<fieldset class="box tabular" id="project_issue_custom_fields"><legend><%=l(:label_custom_field_plural)%></legend>
54
<% @issue_custom_fields.each do |custom_field| %>
55
    <label class="floating">
56
  <%= check_box_tag 'project[issue_custom_field_ids][]', custom_field.id, (@project.all_issue_custom_fields.include? custom_field), (custom_field.is_for_all? ? {:disabled => "disabled"} : {}) %>
57
  <%=h custom_field.name %>
58
  </label>
59
<% end %>
60
<%= hidden_field_tag 'project[issue_custom_field_ids][]', '' %>
61
</fieldset>
62
<% end %>
63
<% end %>
64
<!--[eoform:project]-->
.svn/pristine/d3/d3d65d25f759791112afec8e9891bb6fa5d40f56.svn-base
1
<h2>Good Bye</h2>
2

  
3
<p class="icon icon-example-works"><%= l(:text_say_goodbye) %></p>
4

  
5
<% content_for :header_tags do %>
6
  <%= stylesheet_link_tag 'example', :plugin => 'sample_plugin', :media => "screen" %>
7
<% end %>
.svn/pristine/d3/d3d9bf30f88fdc7250bd3d2626cf179c354940a3.svn-base
1
--- 
2
changes_001: 
3
  id: 1
4
  changeset_id: 100
5
  action: A
6
  path: /test/some/path/in/the/repo
7
  from_path:
8
  from_revision:
9
changes_002: 
10
  id: 2
11
  changeset_id: 100
12
  action: A
13
  path: /test/some/path/elsewhere/in/the/repo
14
  from_path:
15
  from_revision:
16
changes_003: 
17
  id: 3
18
  changeset_id: 101
19
  action: M
20
  path: /test/some/path/in/the/repo
21
  from_path:
22
  from_revision:

Also available in: Unified diff