使用POEdit-仅搜索特定域中的字符串 [英] Using POEdit -- only search for strings in specific domain

查看:89
本文介绍了使用POEdit-仅搜索特定域中的字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个我希望翻译的WordPress主题.

I have created a WordPress theme that I wish to translate.

在主题内,我使用了woocommerce(即<?php _('Your cart', 'woocommerce'); ?>)的一些翻译.

Inside my theme I use some translations from woocommerce (i.e. <?php _('Your cart', 'woocommerce'); ?>).

这些woocommerce字符串,我自然不希望再次翻译,因为它们已经被翻译了.但是,当我使用poedit扫描主题时,它当然会找到所有文本域.

Theese woocommerce strings, I do not wish to translate again, naturally, as they are already translated. But when I use poedit to scan my theme, of course it will find ALL text domains.

所以我的问题是:

如何告诉POEdit仅选择特定文本域中的字符串?

  • __('Something', 'my-text-domain')
  • _e('Something else', 'my-text-domain')
  • __('Something', 'my-text-domain')
  • _e('Something else', 'my-text-domain')

我找到了这个答案:

但是,它似乎对我不起作用.如上所述,我已经将ri:1,3c添加到列表中,但是它并没有任何改变,对于如何处理它,我没有其他线索.

However it does not seem to work for me. I have added ri:1,3c to the list as described, but it doesn't change anything, and I have no other clue as to what to do with it.

看看我是怎么做到的:

推荐答案

GNU gettext工具和Poedit(使用它们)都不支持这种对gettext的特殊滥用.

Neither GNU gettext tools nor Poedit (which uses them) support this particular misuse of gettext.

在gettext中, domain 大致是一件软件" —程序,库,插件,主题.因此,它通常驻留在单个目录树中,并且在其中 单独存在–至少,如果您有多个piece = domain,则可以将它们合理地组织到一些子目录中,从而可以限制提取到.

In gettext, domain is roughly "a piece of software" — a program, a library, a plugin, a theme. As such, it typically resides in a single directory tree and is alone there — or at the very least, if you have multiple pieces=domains, you have them organized sanely into some subdirectories that you can limit the extraction to.

单个文件中混合和匹配域不是您打算如何使用gettext的方法,除了使用您自己的辅助函数(例如,通过将所有woocommerce文本包装到__woo(显然必须定义)中,然后 not 将其添加到Poedit中的关键字列表中.

Mixing and matching domains within a single file as you do is not how gettext was intended to be used, and there’s no reasonable solution to handle it other than using your own helper function, e.g. by wrapping all woocommerce texts into __woo (which you must define, obviously) and not adding that to the list of keywords in Poedit.

这篇关于使用POEdit-仅搜索特定域中的字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆