【发布时间】:2015-03-05 17:25:23
【问题描述】:
基本上我想把本站“Previous Work”和“Next work”的“Previous post”和“Next Post”这两个词改成:http://fontaneriaborja.com/en/portfolio-view/solar-panels-swimming-pool/
我已经进入 /wp-content/themes/CherryFramework/loop/loop-single-portfolio.php 并找到了这段代码:
<!--BEGIN .pager .single-pager -->
<ul class="pager single-pager">
<?php if (get_previous_post()) : ?>
<li class="previous"><?php previous_post_link('%link', theme_locals("prev_post")) ?>
<?php endif; ?>
<?php if (get_next_post()) : ?>
<li class="next"><?php next_post_link('%link', theme_locals("next_post")) ?>
<?php endif; ?>
<!--END .pager .single-pager -->
我相信 theme_locals("prev_post") 和 theme_locals("next_post") 是调用文本的字符串。
理想情况下,我想做的是为诸如 theme_locals("prev_work") 和 theme_locals("next_work") 之类的内容更改和添加一个新字符串,这将为我的 .po 文件生成两个新的翻译。但是,这是我卡住的地方。
这是一个多语言 WordPress 4.1.1 网站,使用 Polylang 和 Template Monster 的主题和樱桃插件。
我已经四处搜索,但没有运气了解它是如何工作的。因此,我们将不胜感激。
感谢您抽出宝贵时间,并提前感谢大家。
最好的
P.S.:我是 Web 开发方面的初学者。 P.S.2:我也在https://wordpress.org/support/topic/add-language-string-in-wordpress 上发布了这个,如果我找到解决方案,我会尽量保持更新。
后编辑:
正如danbahrami 所建议的,我在/wp-content/themes/CherryFramework/includes/locals.php 中找到了一个带有函数'theme_local_init()' 的php 文件。这是部分代码,因为太长了,我没有全部放出来:
<?php
function theme_local_init() {
global $is_cherry_local_init, $cherry_locals_arr;
if ($is_cherry_local_init) return true;
$domain = CURRENT_THEME;
$cherry_locals_arr = array(
//general
'no' => __('No', 'cherry'),
'yes' => __('Yes', $domain),
'slow_speed' => __('Slow', $domain),
'normal_speed' => __('Normal', $domain),
'fast_speed' => __('Fast', $domain),
'normal_size' => __('Normal size', $domain),
'large_size' => __('Large size', $domain),
'font_size' => __('Font Size', $domain),
'lineheight' => __('Lineheight', $domain),
'font_face' => __('Font Face', $domain),
'character_sets' => __('Character Sets', $domain),
'font_style' => __('Font Style', $domain),
'color' => __('Color', $domain),
'import' => __('Import', $domain),
'export' => __('Export', $domain),
'done' => __('Done', $domain),
'error' => __('Error', $domain),
'success' => __('success', $domain),
'upload' => __('Upload', $domain),
'try_again' => __('try again', $domain),
'finish' => __('Finish', $domain),
'skip' => __('Skip this step', $domain),
'install_next' => __('next', $domain),
'none' => __('None', $domain),
'date' => __('Date', $domain),
'title' => __('Title', $domain),
'info' => __('Info', $domain),
'rand' => __('Random', $domain),
'comment_count' => __('Comment count', $domain),
'enable_lightbox' => __('Enable Lightbox', $domain),
'enable_lightbox_desc' => __('Check this to enable the lightbox.', $domain),
'permalink_to' => __('Permalink', $domain),
'read_more' => __('Read more', $domain),
'view_all' => __('View all', $domain),
'width' => __('Width', $domain),
'height' => __('Height', $domain),
'excerpt_length' => __('Excerpt length (words):', $domain),
'link_text' => __('Link Text:', $domain),
'link_url' => __('Link URL', $domain),
'standard' => __('Standard', $domain),
'aside' => __('Aside', $domain),
'quote' => __('Quote', $domain),
'link' => __('Link', $domain),
'image' => __('Image', $domain),
'gallery' => __('Gallery', $domain),
'audio' => __('Audio', $domain),
'video' => __('Video', $domain),
'categories' => __('Categories', $domain),
'tags' => __('Tags', $domain),
'show_all' => __('Show All', $domain),
'search' => __('search', $domain),
'go' => __('Go', $domain),
'prev_post' => __('« Previous post', $domain),
'next_post' => __('Next Post »', $domain),
我相信最后两行是有问题的,但还有更多代码。
【问题讨论】:
-
“theme_locals()”函数正在返回文本。如果你浏览你的主题文件,你会发现在某处定义的函数......可能在名为 functions.php 的文件中。如果你不能并且有一个好的代码编辑器,那么应该有一个工具来搜索所有文件。尝试搜索“function theme_locals”并将以下 {} 括号之间的所有内容粘贴到您的问题中,这将非常有帮助。
-
我想我已经添加了你需要的东西。希望这会有所帮助,谢谢。
标签: php string wordpress translation language-translation