XSLT 的 I18n(或者 XSLT 的 C++ 的 gettext() 和 xgettext 是什么)?
完整的 C++ i18n gettext() “hello world” 示例 展示了使用 gettext() 在 C++ 程序中处理消息的标准方法。 消息目录存储在可移植对象文件中,该文件基于使用 xgettext、msginit 和 msgfmt 直接从 C++ 源代码创建的可移植对象模板文件。 XSLT处理消息的相应方法是什么?
具体来说,要使 C++ hello-world 代码支持 i18n,只需添加两个包含,调用一些设置函数并将字符串包装在对 gettext() 的调用中:
#include <libintl.h>
#include <locale.h>
..
setlocale(LC_ALL, "");
bindtextdomain("hellogt", ".");
textdomain( "hellogt");
std::cout << gettext("hello, world!") << std::endl;
...
然后从源程序中提取英文文本并转换为可移植对象模板以供使用由翻译人员使用实用程序创建机器对象消息目录文件以供运行时程序使用:xgettext、msginit 和 msgfmt。 最后,调用程序时会显示用于将运行时语言识别为西班牙语的 Linux shell 命令。
编写 hello-world 程序的主要目的是连接所有系统部分,以获得一个几乎无用的示例来运行。 因此,正如 C++ 示例所示,对于 Linux 环境中的 C++,我正在寻找相同的东西,但不是 XSLT。
- 在 C++ 示例中,有一组链接到 hellogt 的包含文件和目标文件。 是否有提供 setlocale、bindtextdomain 和 textdomain 功能的 XSLT 代码? 代码如何连接到用户的运行时语言?
- 是否有 XSLT 代码可以像 gettext() 那样通过消息目录文件提供英文文本的运行时转换?
- 是否有实用程序可以从源 XML 文件中提取英语文本以供翻译人员使用,以及将结果转换为运行时可用的消息目录文件(如 xgettext、msginit 和 msgfmt)的程序?
- 用户运行时语言的标识是如何指定的?
例如,我有一个 Javascript 应用程序 Emle,它使用 XSLT 将 XML 处理为 HTML。 这些消息是在特定于语言的 XML 文件的应用程序特定集合中定义的。 它们是使用特定于应用程序的 XSLT 代码提取的。 虽然这涉及#2,但该方法似乎并不适合利用 LaunchPad。 Emle 英文消息文件使用的示例 Emle XSLT 文件
Complete C++ i18n gettext() “hello world” example shows a standard way to handle messages in a C++ program using gettext(). The message catalogs are stored in Portable Object files based upon a Portable Object Template file created directly from the C++ source code using xgettext, msginit and msgfmt. What is the corresponding method for handling messages by XSLT?
Specifically, to make C++ hello-world code support i18n one just adds two includes, calls some setup functions and wraps strings in calls to gettext():
#include <libintl.h>
#include <locale.h>
..
setlocale(LC_ALL, "");
bindtextdomain("hellogt", ".");
textdomain( "hellogt");
std::cout << gettext("hello, world!") << std::endl;
...
Then the English text is extracted from the source program and converted to a Portable Object Template for use by translators who create Machine Object message catalog files for use by the run-time program using utilities programs: xgettext, msginit and msgfmt.
Finally, the Linux shell command for identifying the run-time language as Spanish is shown when the program is invoked.
The main purpose of doing a hello-world program is to connect all of the system parts to get a virtually useless example to function. So, as the C++ example shows for C++ in a Linux environment I am looking for the same thing but for XSLT instead.
- In the C++ example there is a set of include files and object files that are linked into hellogt. Is there code for XSLT that provides the functionality of setlocale, bindtextdomain and textdomain? How does the code connect to the user's runtime language?
- Is there XSLT code that provides run-time conversion from English text via message catalog files like gettext() does?
- Are there utility programs for extracting the Engish text from a source XML file for use by the translators along with programs to convert the results to run-time usable message catalog files like xgettext, msginit and msgfmt do?
- How is the identify of the user runtime language specified?
For example, I have a Javascript application, Emle, that processes XML using XSLT into HTML. The messages are defined in an application specific collection of language specific XML files. They are extracted using application specific XSLT code. Though this speaks to #2 the method does not appear to lend itself to being able to take advantage of translation services like those provided by LaunchPad. An example Emle English message file used by Emle XSLT file
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果非 XML 工具是可接受的,那么这个 Perl 工具会生成 XML 数据文件及其翻译的一组 gettext PO 文件并保持同步。
http://po4a.alioth.debian。 org/man/man3pm/Locale::Po4a::Xml.3pm.php
If non-XML tools are acceptable, then this Perl tool does the job of generating and keeping in sync a set of gettext PO files of an XML data file and its translations.
http://po4a.alioth.debian.org/man/man3pm/Locale::Po4a::Xml.3pm.php
经过一番查看后,我发现了这个: http://xmlguru.cz/2006/10/saxon-gettext< /a>
我还没有完全阅读它,看看它是否以及如何回答您的问题,但我提供了链接,希望它能有所帮助。
After some looking I found this: http://xmlguru.cz/2006/10/saxon-gettext
I've yet to read it fully to see if and how it answers your question, but I offer the link hoping it helps.