summaryrefslogtreecommitdiffstats
path: root/vendor/plugins/gloc-1.1.0/tasks
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2006-12-05 20:45:04 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2006-12-05 20:45:04 +0000
commit96f83cc8f0f032554f771a59da22303cd473b878 (patch)
tree355a0d2ed653a5426c59ebf6a1fe65eba024b4d0 /vendor/plugins/gloc-1.1.0/tasks
parenteabc04d8368824965d3ac8de3fa84502e9c05d38 (diff)
downloadredmine-96f83cc8f0f032554f771a59da22303cd473b878.tar.gz
redmine-96f83cc8f0f032554f771a59da22303cd473b878.zip
trunk moved from /trunk/redmine to /trunk
git-svn-id: http://redmine.rubyforge.org/svn/trunk@67 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'vendor/plugins/gloc-1.1.0/tasks')
-rw-r--r--vendor/plugins/gloc-1.1.0/tasks/gloc.rake30
1 files changed, 30 insertions, 0 deletions
diff --git a/vendor/plugins/gloc-1.1.0/tasks/gloc.rake b/vendor/plugins/gloc-1.1.0/tasks/gloc.rake
new file mode 100644
index 000000000..8da73779e
--- /dev/null
+++ b/vendor/plugins/gloc-1.1.0/tasks/gloc.rake
@@ -0,0 +1,30 @@
+namespace :gloc do
+ desc 'Sorts the keys in the lang ymls'
+ task :sort do
+ dir = ENV['DIR'] || '{.,vendor/plugins/*}/lang'
+ puts "Processing directory #{dir}"
+ files = Dir.glob(File.join(dir,'*.{yaml,yml}'))
+ puts 'No files found.' if files.empty?
+ files.each {|file|
+ puts "Sorting file: #{file}"
+ header = []
+ content = IO.readlines(file)
+ content.each {|line| line.gsub!(/[\s\r\n\t]+$/,'')}
+ content.delete_if {|line| line==''}
+ tmp= []
+ content.each {|x| tmp << x unless tmp.include?(x)}
+ content= tmp
+ header << content.shift if !content.empty? && content[0] =~ /^file_charset:/
+ content.sort!
+ filebak = "#{file}.bak"
+ File.rename file, filebak
+ File.open(file, 'w') {|fout| fout << header.join("\n") << content.join("\n") << "\n"}
+ File.delete filebak
+ # Report duplicates
+ count= {}
+ content.map {|x| x.gsub(/:.+$/, '') }.each {|x| count[x] ||= 0; count[x] += 1}
+ count.delete_if {|k,v|v==1}
+ puts count.keys.sort.map{|x|" WARNING: Duplicate key '#{x}' (#{count[x]} occurances)"}.join("\n") unless count.empty?
+ }
+ end
+end \ No newline at end of file