Extract javascript gettext in Poedit?
我在PHP中使用了" GNU gettext",并且通过使用poedit可以很好地提取PO文件格式
但是,当我在HTML" script"标签内为JavaScript尝试相同的操作时,我什至无法正常工作,我看不到任何javascript支持。
poedit支持除javascript之外的几乎所有语言,否则我做错了
谁能提供javascript的工作示例?
我使用poedit遵循了将近20种语言的所有示例,除javascript之外,所有示例均有效
GNU gettext中所有可用的示例都在
gettext-0.19.7.tar.gz
http://ftp.gnu.org/gnu/gettext/
gettext-0.19.7 gettext-tools examples
这是php示例,我需要对javascript做同样的操作
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | #!@PHP@ -q <? // Example for use of GNU gettext. // This file is in the public domain. // // Source code of the PHP program. setlocale (LC_ALL,""); textdomain ("hello-php"); bindtextdomain ("hello-php","@localedir@"); echo _("Hello, world!"); echo" "; echo printf (_("This program is running as process number %d."),posix_getpid()); echo" "; ?> |
Poedit和
只需将您的JavaScript代码放在单独的
请注意,JavaScript代码在客户端运行,因此您还需要在JavaScript中加载翻译。 考虑到您在PHP代码中只有JS片段(大概很小),对您来说,一个更好的解决方案可能是使用PHP生成JS代码-即在PHP /服务器端进行翻译。
假设您在节点环境中工作,则可以使用此npm软件包来处理这些文件。 我认为无法通过浏览器访问。