initialization
This commit is contained in:
commit
9ff09693ed
92 files changed
+46209
No files matched your search
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
// scripts/generate-docs.php
|
||||
|
||||
class DocumentationGenerator
|
||||
{
|
||||
private array $languages = [
|
||||
'de' => 'Deutsch',
|
||||
'fr' => 'Français',
|
||||
'es' => 'Español',
|
||||
'it' => 'Italiano',
|
||||
'ja' => '日本語',
|
||||
'zh' => '中文'
|
||||
];
|
||||
|
||||
public function generateAllLanguages(): void
|
||||
{
|
||||
$baseTemplate = file_get_contents(__DIR__ . '/../docs/index.html');
|
||||
|
||||
foreach ($this->languages as $code => $name) {
|
||||
$translated = $this->translateContent($baseTemplate, $code);
|
||||
file_put_contents(__DIR__ . "/../docs/docs-{$code}.html", $translated);
|
||||
echo "Generated docs-{$code}.html\n";
|
||||
}
|
||||
}
|
||||
|
||||
private function translateContent(string $content, string $lang): string
|
||||
{
|
||||
// Load translations from JSON files
|
||||
$translations = json_decode(
|
||||
file_get_contents(__DIR__ . "/../locales/{$lang}.json"),
|
||||
true
|
||||
);
|
||||
|
||||
// Replace content with translations
|
||||
$content = str_replace('lang="en"', "lang=\"{$lang}\"", $content);
|
||||
|
||||
// Replace specific content sections
|
||||
foreach ($translations as $key => $value) {
|
||||
$content = str_replace("{{$key}}", $value, $content);
|
||||
}
|
||||
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
|
||||
// Usage
|
||||
$generator = new DocumentationGenerator();
|
||||
$generator->generateAllLanguages();
|
||||
Reference in new issue
Block a user