天道酬勤,学无止境

xgettext

xgettext in OSX to create .po file from PHP code

I'm on Mac OSX, and I'm unable to find a good solution to parse PHP Code and extract the translatable strings. I've tried PoEdit, but it fail with an anti-verbose trunkated error: I've also tried Virtaal, but the app crash when I click "Open", event before the browsing windows appear. I've tried OmegaT, but I think it doesn't support .po files. I can't figure out how it works :( I've also tried xgettext.pl, and it work really well, except it doesn't detect the PHP dgettext() function, and doesn't seem to offer any additional option to configure extra keyword like poEdit does. Man page is here

2022-04-16 02:57:44    分类:问答    php   macos   gettext   xgettext

Django MakeMessages missing xgettext in Windows

Running Django on Windows 7. I'm currently trying to translate a couple of Django templates using the instructions found in the django book chapter 19. I've added a translation tag to the template, loaded I18N, and modified django settings. Then I run django-admin.py makemessages -l en to create the po files. All folders are created but then django terminates with the following error: Error: errors happened while running xgettext on init.py 'xgettext' is not recognized as an internal or external command, operable program or batch file. Reading up on the problem, I've discovered that django

2022-04-04 08:29:43    分类:问答    python   django   windows-7   xgettext

Translate variables with POEdit/xgettext

I am using PHP, Zend Framework and Zend_Translate (gettext adapter). To edit translations I use POEdit which utilizes xgettext to fetch strings to be translated. POEdit (xgettext) will search for keywords to find strings to translate. So, if searching for the keyword translate, POEdit will have no problem finding the 'Text to translate' string when the text is passed to the translate function directly like: echo translate('Text to translate'); But, in ofther cases strings will be passed to Zend functions that will do the translation for me, calling the translate function with a variable as a

2022-03-21 15:32:39    分类:问答    php   variables   gettext   zend-translate   xgettext

Extract translator comments with xgettext from JavaScript (in Python mode)

I have a pretty well-working command that extracts strings from all my .js and .html files (which are just Underscore templates). However, it doesn't seem to work for Translator comments. For example, I have this in one of my .js files: /// TRANSLATORS: The word "manual" stands for manual process gettext("manual"); Using the following command: find . -iname '*.html' -o -iname '*.js' | xargs xgettext --language=Python --from-code=utf-8 --keyword=pgettext:1c,2 --keyword=npgettext:1c,2,3 --add-comments=/ xgettext should extract the comment from the .js file and put it into my .po file like this:

2022-03-14 00:36:21    分类:问答    javascript   python   gettext   xgettext

xgettext does not extract string in HTML attribute

I'm working on a Wordpress site using Timber as templating engine (twig for Wordpress). I want to translate the interface using the Wordpress gettext mechanism via PoEdit (uses xgettext). Template snippet: <form action="/{{ current_language }}/api/search/{{ viewModel.currentSuperCategory.key }}" method="post" class="search-results__search" id="search-form"> <input placeholder="{{ __('City, region, ZIP', text_domain) }}…" class="input search-results__search__input" name="search-query" type="text" data-search-autocomplete /> I'm using PoEdit to extract the strings from the *.twig file. It is

2022-03-10 21:05:44    分类:问答    wordpress   twig   poedit   xgettext   timber

xgettext 和 msgmerge 的字符集问题(Charset problem with xgettext & msgmerge)

问题 我正在尝试制作一个脚本来从我的源文件创建一个 .po 文件并将其与现有文件合并,这样我每次更新我的网站时都不必重做翻译。 我的脚本基于这篇博客文章 http://www.lxg.de/code/playing-with-xgettext 这是我要运行的内容: #!/bin/bash if [ $# -eq 1 ] then if [ -d "./locale/$1" ] then echo '' > "./locale/$1/msg_tmp.po" find . -type f -iname "*.php" | xgettext -j --from-code="utf-8" -o "./locale/$1/msg_tmp.po" -f - msgmerge -N "./locale/$1/msg.po" "./locale/$1/msg_tmp_iconv.po" > "./locale/$1/msg_new.po" mv "./locale/$1/msg_new.po" "./locale/$1/msg.po" rm "./locale/$1/msg_tmp.po" rm "./locale/$1/msg_tmp_iconv.po" else echo The directory locale/$1 does not exist fi else echo Locale

2022-01-15 19:28:40    分类:技术分享    bash   gettext   xgettext

Charset problem with xgettext & msgmerge

I'm trying to make a script to create a .po files from my sources files & merge it with the existing one so I don't have to redo the translation every time I update my website. I'm basing my script on this blog post http://www.lxg.de/code/playing-with-xgettext Here is what I'm trying to run : #!/bin/bash if [ $# -eq 1 ] then if [ -d "./locale/$1" ] then echo '' > "./locale/$1/msg_tmp.po" find . -type f -iname "*.php" | xgettext -j --from-code="utf-8" -o "./locale/$1/msg_tmp.po" -f - msgmerge -N "./locale/$1/msg.po" "./locale/$1/msg_tmp_iconv.po" > "./locale/$1/msg_new.po" mv "./locale/$1/msg

2022-01-12 13:25:46    分类:问答    bash   gettext   xgettext

使用 django 和 xgettext 进行本地化(Localization with django and xgettext)

问题 我正在翻译我的网站,但是当我尝试运行命令时: manage.py makemessages --locale=bs 我经常收到错误,例如: CommandError: errors happened while running xgettext on rjsmin.py xgettext: Non-ASCII string at .\compressor\filters\jsmin\rjsmin.py:59. Please specify the source encoding through --from-code. 我做什么壳? 回答1 我也有同样的问题。 在rjsmin.py的顶部,将“-*-coding:ascii-*-”改为“-*-coding:utf-8-*-”

2022-01-12 00:45:42    分类:技术分享    django   django-templates   xgettext