# frozen_string_literal: true LOCALES = { "ja" => { selector: { "Classes" => "クラス", "Methods" => "メソッド", "Files" => "ファイル", "Versions" => "バージョン", }, title: { "Class List" => "クラス一覧", "Method List" => "メソッド一覧", "File List" => "ファイル一覧", "Version List" => "バージョン一覧", }, }, }.freeze def replace_sidebar_name(dir) regex = %r{\s*([a-zA-Z ]+?)\s*} Dir.glob("#{dir}/*_list.html") do |file| content = File.read(file) new_content = content.dup content.scan(regex) do |_url, name| new_content.gsub!( Regexp.last_match[0], Regexp.last_match[0].gsub(name, LOCALES[ENV["rake_locale"]][:selector][name]) ) end File.write(file, new_content) end end def replace_title(dir) regex = %r{(?: