如何让 Drupal 加载本地化/翻译新安装的自定义块中的字符串?
我刚刚创建了一个模块。为了便于论证,一切正常,并且有很多地方使用了 t('this is the english version')
函数。
t('foo')
函数同时出现在 mymodule.module
文件和 mymodule.tpl.php
文件中。
在我的 drupal 服务器配置中,我已经加载了 LOCALE 和一堆看起来需要的其他模块:(
Internationalization (enabled),
String translation (enabled),
Block languages (enabled),
Contact translation (disabled),
Field translation (enabled),
Translation sets (enabled),
Taxonomy translation (enabled),
Content translation (enabled),
Multilingual content (enabled),
Multilingual forum (disabled),
Menu translation (enabled),
Path translation (disabled),
Translation redirect (disabled),
Multilingual select (enabled),
Synchronize translations (enabled),
Variable translation (disabled),
Translation table (enabled)
抱歉,这是一个巨大的列表,但我不想遗漏任何内容)很重要)
我已经加载了翻译界面,并在我的块使用的“翻译表”和“翻译表”下查找字符串。 “翻译界面”但它们不存在。
我尝试从字符串菜单(在翻译下)重新加载字符串 - 没有成功。 我尝试禁用并重新启用块本身...
我已加载块配置并选择“保存并翻译”(其中我在 drupal 配置下仅获得了 TITLE 选项)
我缺少什么?
我的块是否必须在 mymodule_block_info()
中添加额外的变量 我是否必须创建 mymodule_block_install()
函数?
有人吗?
I've just created a module. For sake of argument, everything works and it's got a number of places where it has used the t('this is the english version')
function.
The t('foo')
function appears in both the mymodule.module
file as well as the mymodule.tpl.php
file.
In my drupal server configuration, I have loaded the LOCALE
and a bunch of other module that look like they're needed:
Internationalization (enabled),
String translation (enabled),
Block languages (enabled),
Contact translation (disabled),
Field translation (enabled),
Translation sets (enabled),
Taxonomy translation (enabled),
Content translation (enabled),
Multilingual content (enabled),
Multilingual forum (disabled),
Menu translation (enabled),
Path translation (disabled),
Translation redirect (disabled),
Multilingual select (enabled),
Synchronize translations (enabled),
Variable translation (disabled),
Translation table (enabled)
(sorry, it's a huge list but I don't want to leave anything out that matters)
I've loaded the translation interface, and looked for the strings under the that my Block uses, "translate table" & "translate interface" but they're not there.
I've tried reloading strings from the strings menu (under translate) - no luck.
I've tried disabling and re-enabling the block itself...
I've loaded block configuration and chosen "save and translate" (where I've only got the TITLE option under drupal configuration)
What am I missing?
Does my block have to have additional variable added to mymodule_block_info()
Do I have to create a mymodule_block_install()
function?
Anyone?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
出于优化原因,Drupal 使用“即时”翻译。
为了在 Drupal 中加载字符串翻译,您通常必须以目标语言访问包含这些字符串的页面。即,如果该块位于您的“联系方式”页面上并且是中文,请使用 访问您的联系方式页面http://mysite.com/zh-hans/node/blah-blah。
在包含未翻译字符串的页面周围单击一下,然后再次访问“已翻译字符串”页面 - 您应该会看到差异。
Drupal uses 'just-in-time' translation for optimization reasons.
In order to load the string translations in Drupal, you typically have to visit the pages with those strings in the target language. I.e., if the block is on your "Contact" page and in Chinese, visit your Contact page using http://mysite.com/zh-hans/node/blah-blah.
Click around a little bit around the pages with untranslated strings, then visit the Translated Strings page again - you should see a difference.