mirror of
https://github.com/seigler/dash-docs
synced 2025-07-27 09:46:12 +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
|
id: wallets-hardware
|
||||||
platform:
|
platform:
|
||||||
name: hardware
|
name: hardware
|
||||||
|
os:
|
||||||
|
name: hardware
|
||||||
---
|
---
|
||||||
|
|
|
@ -5,4 +5,6 @@
|
||||||
id: wallets-web
|
id: wallets-web
|
||||||
platform:
|
platform:
|
||||||
name: web
|
name: web
|
||||||
|
os:
|
||||||
|
name: web
|
||||||
---
|
---
|
||||||
|
|
|
@ -22,6 +22,22 @@ module Jekyll
|
||||||
end
|
end
|
||||||
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
|
class WalletsPageGenerator < Generator
|
||||||
safe true
|
safe true
|
||||||
|
|
||||||
|
@ -29,6 +45,9 @@ module Jekyll
|
||||||
# Get the collection of wallets from _wallets
|
# Get the collection of wallets from _wallets
|
||||||
walletsCol = site.collections['wallets'];
|
walletsCol = site.collections['wallets'];
|
||||||
|
|
||||||
|
# Get the collection of wallets from _wallets
|
||||||
|
platformsCol = site.collections['platforms'];
|
||||||
|
|
||||||
# Output dir
|
# Output dir
|
||||||
# TODO: Make this configurable and "translatable"
|
# TODO: Make this configurable and "translatable"
|
||||||
walletsDir = 'wallets'
|
walletsDir = 'wallets'
|
||||||
|
@ -49,16 +68,22 @@ module Jekyll
|
||||||
locs[lang] = YAML.load_file("_translations/"+file)[lang]
|
locs[lang] = YAML.load_file("_translations/"+file)[lang]
|
||||||
end
|
end
|
||||||
|
|
||||||
puts('----- Generating wallet pages -----')
|
|
||||||
|
|
||||||
# Getting information about each found wallet
|
# 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|
|
walletsCol.docs.each do |doc|
|
||||||
file = doc.path
|
file = doc.path
|
||||||
wallet = YAML.load_file(file)
|
wallet = YAML.load_file(file)
|
||||||
walletPlatforms = wallet['platform']
|
walletPlatforms = wallet['platform']
|
||||||
|
|
||||||
puts(wallet['id'] + ' is loaded. Generating pages...')
|
|
||||||
|
|
||||||
# Going through all available combinations of
|
# Going through all available combinations of
|
||||||
# platforms and OSes
|
# platforms and OSes
|
||||||
walletPlatforms.each do |platform|
|
walletPlatforms.each do |platform|
|
||||||
|
@ -66,20 +91,14 @@ module Jekyll
|
||||||
|
|
||||||
# This allows generation only of valid wallet pages
|
# This allows generation only of valid wallet pages
|
||||||
if platform['name']
|
if platform['name']
|
||||||
|
|
||||||
locs.each do |lang,value|
|
|
||||||
dir = File.join(platform['name'], os['name'], wallet['id'])
|
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)
|
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
|
end
|
||||||
|
end
|
||||||
puts('----- Wallet pages generated -----')
|
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue