如何让 Drupal 加载本地化/翻译新安装的自定义块中的字符串?

发布于 2024-11-29 01:47:53 字数 1187 浏览 1 评论 0原文

我刚刚创建了一个模块。为了便于论证,一切正常,并且有很多地方使用了 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

檐上三寸雪 2024-12-06 01:47:54

出于优化原因,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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文