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

  • SEARCH
  • Home
  • 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 7983947
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T11:06:57+00:00 2026-06-04T11:06:57+00:00

It is stated here that Babel can extract gettext messages for Python and Javascript

  • 0

It is stated here that Babel can extract gettext messages for Python and Javascript files.

Babel comes with a few builtin extractors: python (which extracts
messages from Python source files), javascript, and ignore (which
extracts nothing).

The command line extractor is documented here – but with no examples on usage.

Also in the same pointer above, there is some mention of a config file to be used with extraction, but not much expanded on.

When I run the basic command for the extractor on a dir with js files, I get only the .PO header generated but no messages.

$ pybabel extract   /path/to/js-dir

# Translations template for PROJECT.
# Copyright (C) 2012 ORGANIZATION
# This file is distributed under the same license as the PROJECT project.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2012.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2012-04-22 19:39+1000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 0.9.6\n"

$ 

Here is a sample segment from a js file I’m trying to extract messages for:

else if(data.status == "1"){
    var follow_html = gettext('Follow');
    object.attr("class", 'button follow');
    object.html(follow_html);
    var fav = getFavoriteNumber();
    fav.removeClass("my-favorite-number");
    if(data.count === 0){
        data.count = '';
        fav.text('');
    }else{
        var fmts = ngettext('%s follower', '%s followers', data.count);
        fav.text(interpolate(fmts, [data.count]));
    }
}

I would appreciate it if someone can provide exact CLI options and config settings to make the extraction work, or a pointer to such.

  • 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-04T11:06:58+00:00Added an answer on June 4, 2026 at 11:06 am

    Create a file (babel.cfg) with the following content:

    [javascript:*.js]
    encoding = utf-8
    

    Then, do:

    pybabel extract -F babel.cfg /path/to/js-dir
    

    That should be enough for you to have some message strings.

    BTW, you can consult the help for the extract command by doing:

    pybabel extract --help
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

stated here https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Function the constructor property of an instance of a function object specifies
Here http://source.android.com/source/code-style.html#follow-field-naming-conventions it is stated that : Field Names Non-public, non-static field names start
My disclaimer here is that I started teaching myself C++ about a week ago
I heard that ASP.net MVC does not maintain View State.So,here is my question I
Am I being dense here? StreamReader.ReadLine states that: A line is defined as a
Here are the ways the Eclipse documentation states you can navigate the Content Assist
The VB6 IDE has a very basic undo and redo mechanism, stated here I
In Bjarne Stroustrup's book The C++ Programming Language, it is stated that a derived
Everything is in the title. On the official documentations it is stated that Note
As I've asken on another question HERE it seems that the PackageManager.getInstalledPackages() doesn't play

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.