# LinkShare 插件用到的国际化代码

- Link: https://www.ixiqin.com/2017/09/09/use-the-international-code-of-linkshare-plug-in/
- Published: 2017-09-09T18:17:51+08:00
- Author: 白宦成

```php
    // 初始化代码
    function i10n(){
        $current_locale = get_locale();
        if(!empty($current_locale)){
            $mo_file = dirname(__FILE__).'/languages/'.$current_locale.".mo";
            if (@file_exists($mo_file)&& is_readable($mo_file))
                load_textdomain('link-share',$mo_file);
        }
    }
    add_action('init','i10n');
    ```

上述代码为帮助插件读取 .mo 的语言文件

    ```null
    Text Domain: link-share
    Domain Path: /languages
    ```

上述代码设置插件默认的文本域标识和默认的语言文件路径

    ```null
    // 返回值，不输出
    __( 'New','link-share')
    // 直接输出
    _e( 'New','link-share')
    ```

上述代码为输出翻译后的结果的代码
