使用翻译后的表单资源创建纯资源 DLL

发布于 2024-12-25 05:58:55 字数 308 浏览 5 评论 0原文

我有一个大型应用程序,我想将其迁移到阿拉伯语。我已经定义了在 resourcesstring 关键字下向用户显示的字符串。

我正在使用 Delphi 6 提供的外部翻译管理器。但是,我不太习惯使用该工具。我想创建一个包含所有翻译字符串的纯资源 dll,就像 Delphi ETM 所做的那样,然后通过单击按钮在运行时在语言之间切换。

我能够将资源字符串链接到 Dll,但是表单的标题和提示以及组件属性又如何呢?我根据语言在运行时加载 Dll,但表单属性没有反映,因为它们在 Dll 中不可用。

有正确方向的指针吗???

谢谢 拉胡尔·W

I have a large application which i want to migrate to Arabic. I have defined the strings that we show to the user under the resourcestring keyword.

I am using the External Translation manager provided with Delphi 6. However, I am not very much comfortable using the tool. I want to create a resource only dll with all the translated strings like how the Delphi ETM does, and then switch between languages at run-time at the click of a button.

I was able to link the resourcestrings to the Dll, but how about form's captions and hints and the component properties? I am loading the Dll at runtime depending on the language, but the form properties are not reflecting as they were not available in the Dll.

Any pointers in the right direction ???

Thanks
Rahul W

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

徒留西风 2025-01-01 05:58:55

Delphi 本地化工具和运行时支持的作用是将资源加载(包括表单)从可执行文件重定向到 DLL。表单、它们的组件和控件(非默认属性)作为资源存储到可执行文件中(只要您不在运行时完全创建它们 - 但随后您必须一一设置它们的属性)。

因此,如果您想像标准翻译工具一样工作,则必须以相同的方式工作。 DLL 资源向导的作用是将所有项目 .dfm(以及您手动添加的项目)和资源字符串提取到可以本地化的副本。当应用程序启动时,表单加载代码会检查 .dfm 的加载位置。您应该重写此代码来加载您的资源。

请注意,在运行时更改语言可能需要不同的方法,因为从资源加载整个表单可能会将其“重置”到创建状态。另一方面,与 gettext 等方法相比,它允许本地化的范围远远超出表单文本,包括图像、颜色,并且可以轻松地使控件大小适应新字符串。恕我直言,gettext 适合简单的需求,但是当本地化成为一项复杂的任务并且您可能需要针对非常不同的“文化”进行本地化时,就需要更强大的工具。

What the Delphi localization tool and runtime support do is to redirect resource loading - including forms - from the executable to the DLL. Forms, their components and controls (non default properties) are stored as resources into the executable (as long as you don't create them fully at runtime - but then you would have to set their properties one by one).

Thereby if you want to work alike the standard translation tool you have to work the same way. What the DLL Resource Wizard does is to extract all project .dfm (and those you add manually) and resourcestrings to a copy that can be localized. When an app is started the form loading code checks from where the .dfm should be loaded. You should override this code to load your resources.

Be aware that changes language at runtime may need a different approach, because loading a whole form from resources may "reset" it to the creation state. On the other hand, compared to approaches like gettext, it allows to localize far more than the form text, including images, colors, and to adapt control sizes to the new string easily. IMHO gettext is good for simple needs, but when localization becomes a complex task and you may need to localize for a very different "culture", more powerful tools are needed.

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