diff --git a/README.md b/README.md index 61a6b7a..7dd5fed 100644 --- a/README.md +++ b/README.md @@ -228,6 +228,37 @@ If your server does not have a default timezone set in php.ini, it may return er } ``` +###Multi-language +Enables multi-language support which needs seperate directories for each language in `docs/` folder. + +```json +{ + "languages": { "en": "English", "de": "German" } +} +``` + +Directory structure: +``` +├── docs/ +│ ├── index.md +│ ├── en +│ │ ├── 00_Getting_Started.md +│ │ ├── 01_Examples +│ │ │ ├── 01_GitHub_Flavored_Markdown.md +│ │ │ ├── 05_Code_Highlighting.md +│ │ ├── 05_More_Examples +│ │ │ ├── Hello_World.md +│ │ │ ├── 05_Code_Highlighting.md +│ ├── de +│ │ ├── 00_Getting_Started.md +│ │ ├── 01_Examples +│ │ │ ├── 01_GitHub_Flavored_Markdown.md +│ │ │ ├── 05_Code_Highlighting.md +│ │ ├── 05_More_Examples +│ │ │ ├── Hello_World.md +│ │ │ ├── 05_Code_Highlighting.md +``` + ## Running Remotely Copy the files from the repo to a web server that can run PHP 5.3 or greater. diff --git a/index.php b/index.php index 1960a16..8c40e99 100644 --- a/index.php +++ b/index.php @@ -67,10 +67,31 @@ require_once('libs/functions.php'); $options = get_options(); $tree = get_tree($options['docs_path'], $base_url); -$homepage_url = homepage_url($tree); -$docs_url = docs_url($tree); -$page = load_page($tree); +// If a language is set in the config, rewrite urls based on the language +if ($language === null) { + $homepage_url = homepage_url($tree); + $docs_url = docs_url($tree); +} else { + $homepage_url = "/"; +} + +$docs_url = docs_url($tree); +$url_params = url_params(); + +if (count($options['languages']) > 0 && count($url_params) > 0 && strlen($url_params[0]) > 0) { + $language = array_shift($url_params); + $base_path = "docs/" . $language; +} else { + $language = null; + $base_path = "docs"; +} + +$tree = get_tree($base_path, $base_url, '', true, $language); + + + +$page = load_page($tree, $url_params); // If a timezone has been set in the config file, override the default PHP timezone for this application. if(isset($options['timezone'])) @@ -174,9 +195,17 @@ if ($homepage && $homepage_url !== '/') { View On GitHub + 0) { ?> + $language_name) { ?> + " class="btn btn-primary btn-hero"> + + + + View Documentation + @@ -246,7 +275,7 @@ if ($homepage && $homepage_url !== '/') {