markdown 设置翻译

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown 设置翻译相关的知识,希望对你有一定的参考价值。

## Format 
https://example.com?lang=**[LANGUAGE_ABBR]**  

## Example
Translating to French  
https://example.com?lang=**fr** 

## Code

```
$language = $_GET['lang'];

include "translations/{$language}/homepage.php";

<div class="hero">
    <div class="container">
        <h1 class="title"><?php echo $content->hero['title']; ?></h1>
    </div>
</div>
```

*Note: You'll also need to look into creating a function to set the default as English if a language is defined in the URL (see example below).*

```
function current_language() {
  
    // array of translations available on webpage
    $lang_array = array('de','en','es','fr','it','pt','nl');  
    
    // default language
    $language = 'en'; 

    // get language from parameter
    if ( isset($_GET['lang']) && !empty($_GET['lang']) ) { 
        $language = $_GET['lang'];
    }
    // set to default if language not found in $lang_array
    if ( isset($_GET['lang']) && !in_array($_GET['lang'], $lang_array)) {
        $language = 'en';
    }
    return $language;

}
```

以上是关于markdown 设置翻译的主要内容,如果未能解决你的问题,请参考以下文章

文档翻译经验分享(Markdown)

markdown CopyrightBank FAQ日语翻译

markdown 儿童主题的Wordpress翻译

markdown 翻译员

markdown 用httpclient谷歌翻译

markdown 如何翻译候补名单