diff --git a/README.md b/README.md index d235d286..a8fa2562 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ You can import all translations (complete and incomplete) from transifex using t tx set --auto-remote https://www.transifex.com/projects/p/bitcoinorg/ tx pull -a -s --skip -Then, you can overwrite any specific translation in the _translations folder by one of these files. You might also need to make sure that each .html files (in _layouts, _templates and _redirects.yml) don't serve outdated content for those languages. You should also make sure that no urls or anchor has been changed by translators. +Then, you can overwrite any specific translation in the _translations folder by one of these files. You might also need to make sure that each .html files (in _layouts, _templates and _redirects) don't serve outdated content for those languages. You should also make sure that no urls or anchor has been changed by translators. ### Update source english strings diff --git a/_plugins/sitemap.rb b/_plugins/sitemap.rb index c2da9b32..8d7b80c9 100644 --- a/_plugins/sitemap.rb +++ b/_plugins/sitemap.rb @@ -20,11 +20,13 @@ module Jekyll locs[lang] = YAML.load_file('_translations/'+file)[lang] end #Load redirections - redirects = YAML.load_file('_redirects.yml')['redirects'] + redirects = {} rredirects = {} - redirects.each do |id,value| - dst = value['dst'] - rredirects[dst] = id + Dir.foreach('_redirects') do |file| + next if file == '.' or file == '..' + id = file.split('.')[0] + redirects[id] = YAML.load_file("_redirects/" + file) + rredirects[redirects[id]['dst']] = id end #Create destination directory if does not exists if !File.directory?(site.dest) @@ -44,12 +46,13 @@ module Jekyll sitemap.puts '' sitemap.puts ' http://bitcoin.org/'+lang+'/'+CGI::escape(locs[lang]['url'][id])+'' locs.each do |altlang,value| - #Find appropriate alternative page even with redirections that are not fully deployed in translations altid = id - if redirects.has_key?(id) and redirects[id].has_key?('except') and !redirects[id]['except'].has_key?(altlang) + #If there is a redirection from this page, use the destination as alternate url + if redirects.has_key?(id) and ( !redirects[id].has_key?('except') or !redirects[id]['except'].has_key?(altlang) ) altid = redirects[id]['dst'] end - if rredirects.has_key?(id) + #If there is a disabled redirection to this page, point to the source as alternate url + if rredirects.has_key?(id) and redirects[rredirects[id]].has_key?('except') and redirects[rredirects[id]]['except'].has_key?(altlang) altid = rredirects[id] end next if locs[altlang]['url'][altid].nil? or locs[altlang]['url'][altid] == '' or altlang == lang diff --git a/_plugins/templates.rb b/_plugins/templates.rb index c285ec5a..b077854a 100644 --- a/_plugins/templates.rb +++ b/_plugins/templates.rb @@ -37,8 +37,13 @@ module Jekyll lang = file.split('.')[0] locs[lang] = YAML.load_file("_translations/"+file)[lang] end - #Load redirections - redirects = YAML.load_file('_redirects.yml')['redirects'] + #Load redirections files + redirects = {} + Dir.foreach('_redirects') do |file| + next if file == '.' or file == '..' + id = file.split('.')[0] + redirects[id] = YAML.load_file("_redirects/" + file) + end #Generate each translated page based on templates locs.each do |lang,value| Dir.foreach('_templates') do |file| diff --git a/_redirects.yml b/_redirects.yml deleted file mode 100644 index 622aa1e3..00000000 --- a/_redirects.yml +++ /dev/null @@ -1,13 +0,0 @@ -redirects: - bitcoin-for-enthusiasts: - dst: innovation - except: - ar: true - de: true - es: true - fa: true - it: true - nl: true - ru: true - bitcoin-for-press: - dst: press diff --git a/_redirects/bitcoin-for-enthusiasts.yml b/_redirects/bitcoin-for-enthusiasts.yml new file mode 100644 index 00000000..16b7d58d --- /dev/null +++ b/_redirects/bitcoin-for-enthusiasts.yml @@ -0,0 +1,9 @@ +dst: innovation +except: + ar: true + de: true + es: true + fa: true + it: true + nl: true + ru: true diff --git a/_redirects/bitcoin-for-press.yml b/_redirects/bitcoin-for-press.yml new file mode 100644 index 00000000..0bc35ab8 --- /dev/null +++ b/_redirects/bitcoin-for-press.yml @@ -0,0 +1 @@ +dst: press