mirror of
https://github.com/seigler/dash-docs
synced 2025-07-27 01:36:13 +00:00
Adds support for translation of platform pages
This commit is contained in:
parent
f5a483c86b
commit
43ec650bd4
3 changed files with 43 additions and 20 deletions
|
@ -5,4 +5,6 @@
|
|||
id: wallets-hardware
|
||||
platform:
|
||||
name: hardware
|
||||
os:
|
||||
name: hardware
|
||||
---
|
||||
|
|
|
@ -5,4 +5,6 @@
|
|||
id: wallets-web
|
||||
platform:
|
||||
name: web
|
||||
os:
|
||||
name: web
|
||||
---
|
||||
|
|
|
@ -22,6 +22,22 @@ module Jekyll
|
|||
end
|
||||
end
|
||||
|
||||
class PlatformPage < Page
|
||||
def initialize(site, base, dir, platform, os, lang)
|
||||
@site = site
|
||||
@base = base
|
||||
@dir = dir
|
||||
@name = 'index.html'
|
||||
|
||||
self.process(@name)
|
||||
self.read_yaml(File.join(base, '_layouts'), 'wallet-platform.html')
|
||||
self.data['platform'] = platform
|
||||
self.data['os'] = os
|
||||
self.data['id'] = ['wallets', platform['name'], os['name']].join('-')
|
||||
self.data['lang'] = lang
|
||||
end
|
||||
end
|
||||
|
||||
class WalletsPageGenerator < Generator
|
||||
safe true
|
||||
|
||||
|
@ -29,6 +45,9 @@ module Jekyll
|
|||
# Get the collection of wallets from _wallets
|
||||
walletsCol = site.collections['wallets'];
|
||||
|
||||
# Get the collection of wallets from _wallets
|
||||
platformsCol = site.collections['platforms'];
|
||||
|
||||
# Output dir
|
||||
# TODO: Make this configurable and "translatable"
|
||||
walletsDir = 'wallets'
|
||||
|
@ -49,16 +68,22 @@ module Jekyll
|
|||
locs[lang] = YAML.load_file("_translations/"+file)[lang]
|
||||
end
|
||||
|
||||
puts('----- Generating wallet pages -----')
|
||||
|
||||
# Getting information about each found wallet
|
||||
locs.each do |lang,value|
|
||||
platformsCol.docs.each do |doc|
|
||||
file = doc.path
|
||||
data = YAML.load_file(file)
|
||||
platform = data['platform']
|
||||
os = data['os']
|
||||
dir = File.join(platform['name'], os['name'])
|
||||
site.pages << PlatformPage.new(site, site.source, File.join(lang, walletsDir, dir), platform, os, lang)
|
||||
end
|
||||
|
||||
walletsCol.docs.each do |doc|
|
||||
file = doc.path
|
||||
wallet = YAML.load_file(file)
|
||||
walletPlatforms = wallet['platform']
|
||||
|
||||
puts(wallet['id'] + ' is loaded. Generating pages...')
|
||||
|
||||
# Going through all available combinations of
|
||||
# platforms and OSes
|
||||
walletPlatforms.each do |platform|
|
||||
|
@ -66,22 +91,16 @@ module Jekyll
|
|||
|
||||
# This allows generation only of valid wallet pages
|
||||
if platform['name']
|
||||
|
||||
locs.each do |lang,value|
|
||||
dir = File.join(platform['name'], os['name'], wallet['id'])
|
||||
site.pages << WalletPage.new(site, site.source, File.join(lang, walletsDir, dir), wallet, platform, os, lang)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
puts(wallet['id'] + ' is processed.')
|
||||
end
|
||||
|
||||
puts('----- Wallet pages generated -----')
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue