473,382 Members | 1,775 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

gettext and "disambiguating comments"

I'm looking at the gettext module for the first time and
learning how to write internationalized code in Python.

Naturally, I also looked at the original Gnu gettext
manual, which mentions that comments can be captured
into the .po (.pot?) file for translators' benefit:

/* Comment right before the gettext call, obviously in C */
printf(_("Apparently ambiguous string to translate"));

This will get captured into the .po file, according to the
gettext manual and appear as a comment right before
the msgid (i.e. next to the line number reference).

Is there an equivalent Python gettext idiom? I've tried the
obvious

# Comment right before the gettext call, now in Python
print _("Apparently ambiguous string to translate")

But this is ignored by both pygettext and xgettext.

I also saw some discussion (from the Gnome project)
about gettext variations which capture comments from
within the text:

_("comment for translators| Spam")

But, Python's gettext happily renders the entire comment
into the program, so this isn't doing anything either.

Clearly, I could edit the .pot file after creation to
include comments, but that's probably undesireable
since the file is meant to be machine-generated.

I have no pressing immediate need for this functionality
(that I know of), but I'd like to understand how to access
this capability if it exists.

--
Terry Hancock ( hancock at anansispaceworks.com )
Anansi Spaceworks http://www.anansispaceworks.com

Jul 21 '05 #1
1 2131
Terry Hancock wrote:
/* Comment right before the gettext call, obviously in C */
printf(_("Apparently ambiguous string to translate"));

This will get captured into the .po file, according to the
gettext manual and appear as a comment right before
the msgid (i.e. next to the line number reference).
Not automatically. You need to pass the -c option to xgettext
to make that happen, preferably using a tag:

/* TRANSLATORS: Comment right before the gettext call */
Is there an equivalent Python gettext idiom? I've tried the
obvious

# Comment right before the gettext call, now in Python
print _("Apparently ambiguous string to translate")

But this is ignored by both pygettext and xgettext.


Did you give -c to xgettext? It works for me, for xgettext
0.14.5. -c appears to be unimplemented in pygettext.

Regards,
Martin
Jul 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Trebor A. Rude | last post by:
I'm new to Perl (although I have about 7 years of C++ experience), and I was just wondering which of these two equivalent statements the group thinks is "better", and why: push @command, map...
11
by: MLH | last post by:
I copied the following code snippet from A97 HELP. Am getting an error at compile time suggesting there's a problem with the first line (compile error, user-defined type not defined). It is likely...
2
by: George Sew | last post by:
Hi there, When you right-click on a pdf file in Windows, you can visualize the "Title" and the "Comments" fields under the "Summary" tab. I am trying to retrieve these fields so that I can put...
1
by: DJ DIGI | last post by:
Hello Everyone, I'm attempting to design a small web app to obtain customer feedback. The issue is when a user inputs >4000 characters in the COMMENTS section I get the following Err Msg: ...
1
by: Skip Sailors | last post by:
I want code I write to have XML comments that are correct and I want the compiler to fail to build is I mess up a comment, but I don't want generated code to cause a build failure. Is there a way...
9
by: Gary | last post by:
Hi all! I've taken some time on learning the difference between "pointers to const variables" and "const pointer variables". The question is: in the following code, can we change the contents of...
12
by: Matthew Wilson | last post by:
Hi, we are getting a lot of spam through our PHP Feedback form, and have set up a new field 'prove you're human', asking them to do some simple maths. What is the command for the PHP script...
2
by: Bill H | last post by:
I was working on some php code yesterday and one of the lines in it was: print "<?xml version=\"1.0\" ?>\n"; when I tried to run it I would get an unexpected $end on the last line of the...
14
by: confusedfusion | last post by:
Not sure how many form submissions that have been lost over the years before I started but the company has a contact form that the required fields when validation fails the error message is going...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.