diff options
-rwxr-xr-x | script/import-translated-page | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/script/import-translated-page b/script/import-translated-page index 6a570e4f0..bcbb602a1 100755 --- a/script/import-translated-page +++ b/script/import-translated-page @@ -3,6 +3,55 @@ require 'optparse' require 'pathname' +class HelpMessage + MESSAGE = <<-EOF +About: + + Translators will deliver a page with the source language replaced with the + desired target language. We still need to do some extra work before the page + can be released. import-translated-page runs each line through the LineProcessor + and modifies the line if a matcher is hit. There are some matchers that + import-translated-page cannot process automatically; these will need to be + changed by you. Run the command without the --force option to view these + warnings. + + Currently supported processors: + + Prefixes layouts with the lang (e.g. layout: es/page) unless the lang is + "en". + + Replaces {{ site.baseurl }} with {{ page.baseurl }} for internal page links. + + Keeps {{ site.baseurl }} for asset links. + + Removes single line redirects from non EN pages. + + Currently unsupported processors: + + A yaml list of redirects. + + Templates included with the liquid "include" tag. The template being + included needs to be prefixed with the locale. + +Examples: + + Check the Spanish translation of the "community.md" page for unsupported + matches: + + $ import-translated-page --lang=es community.md + + Manually fix any unsupported matches. + + Import the page in to the site: + + $ import-translated-page --lang=es community.md > es/community.md +EOF + + def self.print + MESSAGE + end +end + class LineProcessor MATCHERS = { :layout => /^layout:\s*(\S*)$/i, @@ -88,6 +137,9 @@ options = {} optionparser = OptionParser.new do |opts| opts.banner = "Usage: #{ __FILE__ } [options] source_file" + opts.separator "" + opts.separator "Options:" + opts.on("--force", "Ignore warnings and continue processing the source_file") do |f| options[:force] = f end @@ -108,6 +160,9 @@ optionparser = OptionParser.new do |opts| opts.on("-o", "--output-file=FILE", "File to write the processed text to") do |o| options[:output_file] = o end + + opts.separator "" + opts.separator HelpMessage.print end optionparser.parse! |