mirror of
https://github.com/seigler/dash-docs
synced 2025-07-27 09:46:12 +00:00
Clean and improve redirects.rb
Use _redirects/ for more consistency with other plugins Fix an inaccurate redirection association in sitemap.rb
This commit is contained in:
parent
dbb1823e69
commit
d58a1690da
6 changed files with 28 additions and 23 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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 '<url>'
|
||||
sitemap.puts ' <loc>http://bitcoin.org/'+lang+'/'+CGI::escape(locs[lang]['url'][id])+'</loc>'
|
||||
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
|
||||
|
|
|
@ -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|
|
||||
|
|
|
@ -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
|
9
_redirects/bitcoin-for-enthusiasts.yml
Normal file
9
_redirects/bitcoin-for-enthusiasts.yml
Normal file
|
@ -0,0 +1,9 @@
|
|||
dst: innovation
|
||||
except:
|
||||
ar: true
|
||||
de: true
|
||||
es: true
|
||||
fa: true
|
||||
it: true
|
||||
nl: true
|
||||
ru: true
|
1
_redirects/bitcoin-for-press.yml
Normal file
1
_redirects/bitcoin-for-press.yml
Normal file
|
@ -0,0 +1 @@
|
|||
dst: press
|
Loading…
Add table
Add a link
Reference in a new issue