Qtranslate使用方法

2014.03.23 2366 人浏览 留言

基本使用方法

  1. <!--:zh-->正文内容<!--:--><!--:en-->Content<!--:-->
  1. <?php _e("<!--:zh-->灰狼<!--:--><!--:en-->Huilang<!--:--></h3>");?>

WP主题自定义域中英化

  1. <?php echo get_post_meta(get_the_ID(), "price", true);?>

改成

  1. <?php echo _e(apply_filters(' ', _(get_post_meta($post->ID, 'price', true)))); ?>

WP主题图片/LOGO中英化

  1. <?php if(qtrans_getLanguage()=='zh'): ?>
  2.     <img src="<?php bloginfo('template_url')>/images/logo_zh.png" />
  3. <?php endif; ?>
  4. <?php if(qtrans_getLanguage()=='en'): ?>
  5.     <img src="<?php bloginfo('template_url')>/images/logo_en.png" />
  6. <?php endif; ?>

将主题语言切换按钮插入到主题模板。

  1. <?php echo qtrans_generateLanguageSelectCode('both'); ?>
  1. <?php echo qtrans_generateLanguageSelectCode('image'); ?>

语言包

  1. load_theme_textdomain('huilang', TEMPLATEPATH . '/lang');  //载入语言包
  2. <?php _e('English', 'huilang'); ?>   //调用

制作好语言包后放在主题目录lang文件夹下即可

PS:插件作者还是中国人~

文章地址:https://huilang.me/isay/qtranslate-shi-yong-fang-fa/

回复本文

电子邮件地址不会被公开。 必填项已用*标注

icon_wink.gif icon_neutral.gif icon_mad.gif icon_twisted.gif icon_smile.gif icon_eek.gif icon_sad.gif icon_rolleyes.gif icon_razz.gif icon_redface.gif icon_surprised.gif icon_mrgreen.gif icon_lol.gif icon_idea.gif icon_biggrin.gif icon_evil.gif icon_cry.gif icon_cool.gif icon_arrow.gif icon_confused.gif icon_question.gif icon_exclaim.gif