route_translator 2.0.1 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,32 +0,0 @@
1
- require "rails"
2
-
3
- module Rails
4
- class Application
5
- if defined?(RoutesReloader)
6
- class RoutesReloader
7
- alias :reload_without_translator! :reload!
8
-
9
- def reload!
10
- result = reload_without_translator!
11
-
12
- route_sets.each do |routes|
13
- routes.default_locale = I18n.default_locale
14
- routes.translate_from_file
15
- end
16
-
17
- result
18
- end
19
- end
20
- else
21
- alias :reload_routes_without_translator! :reload_routes!
22
- def reload_routes!
23
- result = reload_routes_without_translator!
24
-
25
- self.routes.default_locale = I18n.default_locale
26
- self.routes.translate_from_file
27
-
28
- result
29
- end
30
- end
31
- end
32
- end
@@ -1,11 +0,0 @@
1
- module ActionDispatch
2
- class TestRequest < Request
3
- def initialize(env = {})
4
- super(DEFAULT_ENV.merge(env))
5
-
6
- self.host = 'test.host'
7
- self.remote_addr = '0.0.0.0'
8
- self.user_agent = 'Rails Testing'
9
- end
10
- end
11
- end
@@ -1,35 +0,0 @@
1
- namespace :translate_routes => :environment do
2
-
3
- desc "Updates yaml translation files for the given languages"
4
- task :update_yaml, :langs, :needs => :environment do |task, args|
5
- segments = ActionController::Routing::Translator.original_static_segments
6
-
7
- if args[:langs].is_a?(String)
8
- langs = args[:langs] + ' ' + ActionController::Routing::Translator.default_locale
9
- langs.split.uniq.each do |lang|
10
-
11
- file_path = File.join(config_path, "routes_#{lang}.yml");
12
-
13
- if File.exists?(file_path)
14
- puts "Updating #{file_path}"
15
- translations = YAML.load_file(file_path)
16
- f = File.open(file_path,'w')
17
- else
18
- puts "Creating #{file_path}"
19
- translations = {}
20
- f = File.new(file_path, 'w')
21
- end
22
-
23
- f.write "#{lang}:\n"
24
- segments.each do |s|
25
- translation = translations[lang][s] rescue ''
26
- f.write " #{s}: #{translation}\n"
27
- end
28
- f.close
29
- end
30
-
31
- else
32
- puts 'Missing parameters, usage example: rake translate_routes:update_yaml["fr de es"]'
33
- end
34
- end
35
- end