Skip to content

Commit

Permalink
refactor(lang) Refactor
Browse files Browse the repository at this point in the history
- 重构
  • Loading branch information
idawnlight committed Jul 18, 2017
1 parent 2d6adb9 commit 630be72
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 55 deletions.
6 changes: 1 addition & 5 deletions archive.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,7 @@
<?php $this->excerpt(80, '...'); ?> &nbsp;&nbsp;&nbsp;
<span>
<a href="<?php $this->permalink(); ?>" target="_self">
<?php if ($this->options->langis == '0'): ?>
Continue Reading
<?php elseif ($this->options->langis == '1'): ?>
继续阅读
<?php endif; ?>
<?php echo tranMsg("Continue Reading", "继续阅读", $this->options->langis) ?>
</a>
</span>
</div>
Expand Down
2 changes: 1 addition & 1 deletion comments.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@
<?php else: ?>

<div class="comments__closed">
<span id="commentCount">评论已关闭</span>
<span id="commentCount"><?php echo tranMsg("Comment has been closed", "评论已关闭", $this->options->langis) ?></span>
</div>

<?php endif; ?>
Expand Down
7 changes: 7 additions & 0 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -287,3 +287,10 @@ function copyright()
{
echo '<script>console.log("\n %c © Material ' . MATERIAL_VERSION . ' | https://github.com/LiMingYuGuang/typecho-theme-material %c \n","color:#455a64;background:#e0e0e0;padding:5px 0;border-top-left-radius:5px;border-bottom-left-radius:5px;","color:#455a64;background:#e0e0e0;padding:5px 0;border-top-right-radius:5px;border-bottom-right-radius:5px;")</script>';
}

//Language
//Usage tranMsg("Newer", "新篇", $this->options->langis)
function tranMsg($eng, $chs, $l)
{
return ($l == "0") ? $eng : $chs ;
}
6 changes: 1 addition & 5 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,11 +213,7 @@
<?php $this->excerpt(80, '...'); ?> &nbsp;&nbsp;&nbsp;
<span>
<a href="<?php $this->permalink(); ?>" target="_self">
<?php if ($this->options->langis == '0'): ?>
Continue Reading
<?php elseif ($this->options->langis == '1'): ?>
继续阅读
<?php endif; ?>
<?php echo tranMsg("Continue Reading", "继续阅读", $this->options->langis) ?>
</a>
</span>
</div>
Expand Down
24 changes: 7 additions & 17 deletions post.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,37 +75,27 @@
<?php endif;?>
<a class="md-menu-list-a" href="https://www.facebook.com/sharer/sharer.php?u=<?php $this->options->permalink(); ?>">
<li class="mdl-menu__item">
<?php if ($this->options->langis == '0'): ?> Share to Facebook
<?php else: ?> 分享到 Facebook
<?php endif; ?>
<?php echo tranMsg("Share to Facebook", "分享到 Facebook", $this->options->langis) ?>
</li>
</a>
<a class="md-menu-list-a" href="https://telegram.me/share/url?url=<?php $this->options->permalink(); ?>&text=<?php $this->options->title(); ?>" >
<li class="mdl-menu__item">
<?php if ($this->options->langis == '0'): ?> Share to Telegram
<?php else: ?> 分享到 Telegram
<?php endif; ?>
<?php echo tranMsg("Share to Telegram", "分享到 Telegram", $this->options->langis) ?>
</li>
</a>
<a class="md-menu-list-a" href="https://twitter.com/intent/tweet?text=<?php $this->title(); ?>&url=<?php $this->permalink() ?>&via=<?php $this->user->screenName(); ?>">
<li class="mdl-menu__item">
<?php if ($this->options->langis == '0'): ?> Share to Twitter
<?php else: ?> 分享到 Twitter
<?php endif; ?>
<?php echo tranMsg("Share to Twitter", "分享到 Twitter", $this->options->langis) ?>
</li>
</a>
<a class="md-menu-list-a" href="https://plus.google.com/share?url=<?php $this->permalink(); ?>" onclick="javascript:window.open(this.href,'', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=600,width=600');return false;">
<li class="mdl-menu__item">
<?php if ($this->options->langis == '0'): ?> Share to Google+
<?php else: ?> 分享到 Google+
<?php endif; ?>
<?php echo tranMsg("Share to Google+", "分享到 Google+", $this->options->langis) ?>
</li>
</a>
<a class="md-menu-list-a" href="http://service.weibo.com/share/share.php?appkey=&title=<?php $this->options->title(); ?>&url=<?php $this->options->permalink(); ?>&pic=&searchPic=false&style=simple ">
<li class="mdl-menu__item">
<?php if ($this->options->langis == '0'): ?> Share to Weibo
<?php else: ?> 分享到新浪微博
<?php endif; ?>
<?php echo tranMsg("Share to Weibo", "分享到 新浪微博", $this->options->langis) ?>
</li>
</a>
</ul>
Expand All @@ -125,9 +115,9 @@
<?php $this->theNext('%s', null, array('title' => '
<button class="mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--icon mdl-color--white mdl-color-text--grey-900" role="presentation">
<i class="material-icons">arrow_back</i>
</button>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Newer', 'tagClass' => 'prev-content')); ?>
</button>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' . tranMsg("Newer", "新篇", $this->options->langis) . '', 'tagClass' => 'prev-content')); ?>
<div class="section-spacer"></div>
<?php $this->thePrev('%s', null, array('title' => 'Older&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<button class="mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--icon mdl-color--white mdl-color-text--grey-900" role="presentation">
<?php $this->thePrev('%s', null, array('title' => tranMsg("Older", "旧篇", $this->options->langis) . '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<button class="mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--icon mdl-color--white mdl-color-text--grey-900" role="presentation">
<i class="material-icons">arrow_forward</i>
</button>', 'tagClass' => 'prev-content')); ?>
</nav>
Expand Down
36 changes: 9 additions & 27 deletions sidebar.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,34 +56,26 @@
<li>
<a href="<?php $this->options->adminUrl(); ?>" tabindex="-1">
<i class="material-icons sidebar-material-icons sidebar-indent-left1pc-element">account_circle</i>
<?php if ($this->options->langis == '0'): ?> Profile
<?php elseif ($this->options->langis == '1'): ?> 用户概要
<?php endif; ?>
<?php echo tranMsg("Profile", "用户概要", $this->options->langis) ?>
</a>
</li>
<li>
<a href="<?php $this->options->adminUrl('options-theme.php'); ?>" tabindex="-1">
<i class="material-icons sidebar-material-icons sidebar-indent-left1pc-element">settings</i>
<?php if ($this->options->langis == '0'): ?> Settings
<?php elseif ($this->options->langis == '1'): ?> 设置外观
<?php endif; ?>
<?php echo tranMsg("Settings", "设置外观", $this->options->langis) ?>
</a>
</li>
<li>
<a href="<?php $this->options->logoutUrl(); ?>" class="md-menu-list-a" tabindex="-1">
<i class="material-icons sidebar-material-icons sidebar-indent-left1pc-element">exit_to_app</i>
<?php if ($this->options->langis == '0'): ?> Exit
<?php elseif ($this->options->langis == '1'): ?> 退出登录
<?php endif; ?>
<?php echo tranMsg("Exit", "退出登录", $this->options->langis) ?>
</a>
</li>
<?php else: ?>
<li>
<a href="<?php $this->options->loginUrl(); ?>" class="md-menu-list-a" tabindex="-1">
<i class="material-icons sidebar-material-icons sidebar-indent-left1pc-element">fingerprint</i>
<?php if ($this->options->langis == '0'): ?> Login
<?php elseif ($this->options->langis == '1'): ?> 用户登录
<?php endif; ?>
<?php echo tranMsg("Login", "用户登录", $this->options->langis) ?>
</a>
</li>
<?php endif; ?>
Expand All @@ -94,19 +86,15 @@
<li id="sidebar-first-li">
<a href="<?php $this->options->siteUrl(); ?>" target="_self">
<i class="material-icons sidebar-material-icons">home</i>
<?php if ($this->options->langis == '0'): ?> Homepage
<?php elseif ($this->options->langis == '1'): ?> 主页
<?php endif; ?>
<?php echo tranMsg("Homepage", "主页", $this->options->langis) ?>
</a>
</li>

<!-- Archives -->
<li class="dropdown">
<a href="#" class="ripple-effect dropdown-toggle" data-toggle="dropdown">
<i class="material-icons sidebar-material-icons">inbox</i>
<?php if ($this->options->langis == '0'): ?> Archives
<?php elseif ($this->options->langis == '1'): ?> 归档
<?php endif; ?>
<?php echo tranMsg("Archives", "归档", $this->options->langis) ?>
<b class="caret"></b>
</a>
<ul class="dropdown-menu">
Expand All @@ -125,9 +113,7 @@
<li class="dropdown">
<a href="#" class="ripple-effect dropdown-toggle" data-toggle="dropdown">
<i class="material-icons sidebar-material-icons">apps</i>
<?php if ($this->options->langis == '0'): ?> Categories
<?php elseif ($this->options->langis == '1'): ?> 分类
<?php endif; ?>
<?php echo tranMsg("Categories", "分类", $this->options->langis) ?>
<b class="caret"></b>
</a>
<ul class="dropdown-menu" for="show-category-button">
Expand Down Expand Up @@ -163,9 +149,7 @@
<!-- Article Numebr -->
<li>
<a href="#">
<?php if ($this->options->langis == '0'): ?> Article Number
<?php elseif ($this->options->langis == '1'): ?> 文章总数
<?php endif; ?>
<?php echo tranMsg("Article Number", "文章总数", $this->options->langis) ?>
<span class="sidebar-badge"><?php echo $stat->publishedPostsNum;?></span>
</a>
</li>
Expand All @@ -177,9 +161,7 @@
<!-- Sidebar bottom text -->
<a href="https://github.com/LiMingYuGuang/typecho-theme-material" target="_blank" class="sidebar-footer-text-a">
<div class="sidebar-text mdl-button mdl-js-button mdl-js-ripple-effect sidebar-footer-text-div" data-upgraded=",MaterialButton,MaterialRipple">
<?php if ($this->options->langis == '0'): ?> Theme - Material
<?php elseif ($this->options->langis == '1'): ?> 主题 - Material
<?php endif; ?>
<?php echo tranMsg("Theme - Material", "主题 - Material", $this->options->langis) ?>
<span class="sidebar-badge badge-circle">i</span>
</div>
</a>
Expand Down

0 comments on commit 630be72

Please sign in to comment.