Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8416035
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T01:37:30+00:00 2026-06-10T01:37:30+00:00

I have a pretty well-working command that extracts strings from all my .js and

  • 0

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:

#. TRANSLATORS: The word "manual" stands for manual process
#: tax.js:200 
msgid "manual"     msgstr "" 

But it doesn’t. Am I doing something wrong here or are translator comments just not working in Python mode?

EDIT: I have accepted John Flatness’ answer as the correct one, however I did find a workaround that enables me to still use the Python mode and extract translator comments. It’s not perfect, because it actually leaves some of the syntax inside the comments:

In my tax.js file:

/*
# This is a translator comment */
gettext("What is this?");

Run this command:

find . -iname '*.html' -o -iname '*.js' | xargs xgettext --language=Python --from-code=utf-8 --keyword=pgettext:1c,2 --keyword=npgettext:1c,2,3 -c

Result in .po file:

#. This is a translator comment */
#: tax.js:201
msgid "What is this?"
msgstr ""

As You can see, the only problems are that:

  1. I have to write the comment in 2 lines
  2. The comment terminator */ is left in the translator comments

This should not be much of an issue in most cases, though.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T01:37:32+00:00Added an answer on June 10, 2026 at 1:37 am

    The problem is that you’re telling xgettext that the source is Python, when it’s really JavaScript.

    This may make it work “well enough” for many cases, but I’d assume what’s tripping things up here is that Python doesn’t do one-liner comments with //, it uses #.

    There’s a project on Github that adds javascript support to the gettext tools. I’m not sure of its current status, and you’d have to build from source to use it. Otherwise, I suppose you could try other languages that xgettext does support that have more C/C++/Java-like syntax.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have this pretty well known script that i am trying to get working,
The question seems pretty well formulated I have a virtual machine which implements only
Well, the subject pretty much says it all. I have code to unzip and
Well, I'm gonna be pretty straightforward here, I just have a piece of code
I have a core data app set up, and everything is working pretty well.
I have this anchor locating regex working pretty well: $p = '%<a.*\s+name=(.*)\s*>(?:.*)</a>%im'; It matches
i am using this tutorial for progress which is working pretty well , i
I have jQuery validation working pretty well using a dialog for the error messages.
I have got a comment script written in PHP working pretty well. It saves
I have a simple create user wizard control and It's working pretty well upto

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.