Added support for generating translated guides (stored in source/<LANG>) via setting the LANG environment variable

This commit is contained in:
Karel Minarik
2011-01-01 17:54:02 +01:00
parent 65d389955f
commit 56221faecd

View File

@@ -38,6 +38,10 @@
# Note that if you are working on a guide generation will by default process
# only that one, so ONLY is rarely used nowadays.
#
# LANG
# Use LANG when you want to generate translated guides in <tt>source/<LANG></tt>
# folder (such as <tt>source/es</tt>). Ignore it when generating English guides.
#
# EDGE
# Set to "1" to indicate generated guides should be marked as edge. This
# inserts a badge and changes the preamble of the home page.
@@ -63,6 +67,7 @@ module RailsGuides
GUIDES_RE = /\.(?:textile|html\.erb)$/
def initialize(output=nil)
@lang = ENV['LANG']
initialize_dirs(output)
create_output_dir_if_needed
set_flags_from_environment
@@ -76,8 +81,8 @@ module RailsGuides
private
def initialize_dirs(output)
@guides_dir = File.join(File.dirname(__FILE__), '..')
@source_dir = File.join(@guides_dir, "source")
@output_dir = output || File.join(@guides_dir, "output")
@source_dir = File.join(@guides_dir, "source", @lang.to_s)
@output_dir = output || File.join(@guides_dir, "output", @lang.to_s)
end
def create_output_dir_if_needed