Skip to content

Commit

Permalink
Add ability to translate rails guides documents.yaml
Browse files Browse the repository at this point in the history
Some translations of rails guides has their own documents.yaml, for example

Japanese:
https://github.com/yasslab/railsguides.jp/blob/japanese/guides/source/documents.yaml

Traditional Chinese:
https://github.com/docrails-tw/guides/blob/master/rails_guides/helpers.rb#L21,L27
https://github.com/docrails-tw/guides/blob/master/source/documents_zh-TW.yaml

The [Translating Rails Guides](https://github.com/rails/docrails/wiki/translating-rails-guides) says

> Copy the contents of guides/source into your own language directory and translate them.

So that sounds ok to copy guides/source/documents.yaml into language
specific directly and translating them like other markdown files.
  • Loading branch information
hanachin committed May 12, 2015
1 parent 581a212 commit a8d0176
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion guides/rails_guides/generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def generate_guide(guide, output_file)
layout = kindle? ? 'kindle/layout' : 'layout'

File.open(output_path, 'w') do |f|
view = ActionView::Base.new(source_dir, :edge => @edge, :version => @version, :mobi => "kindle/#{mobi}")
view = ActionView::Base.new(source_dir, :edge => @edge, :version => @version, :mobi => "kindle/#{mobi}", :lang => @lang)
view.extend(Helpers)

if guide =~ /\.(\w+)\.erb$/
Expand Down
2 changes: 1 addition & 1 deletion guides/rails_guides/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def guide(name, url, options = {}, &block)
end

def documents_by_section
@documents_by_section ||= YAML.load_file(File.expand_path('../../source/documents.yaml', __FILE__))
@documents_by_section ||= YAML.load_file(File.expand_path("../../source/#@lang/documents.yaml", __FILE__))
end

def documents_flat
Expand Down

0 comments on commit a8d0176

Please sign in to comment.