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 5847799
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:46:11+00:00 2026-05-22T12:46:11+00:00

really struggling with this one. I’ve recently setup a bash shell script to extract,

  • 0

really struggling with this one.

I’ve recently setup a bash shell script to extract, concat and deduplicate the strings to translate out of a whole webite’s view pages (MVC framework in use), it looks something like this:

for x in *.php; do xgettext --no-wrap --language=PHP -e --flag=_:1:pass-c-format -a "$x" -o "${x%.php}.pot"; done
msgcat -u -s --output-file=$WEBSITENAME-concat.pot *.pot
msguniq -u --output-file=$WEBSITENAME-unique.pot $WEBSITENAME-concat.pot
msgmerge -s -v -U $WEBSITENAME.po $WEBSITENAME-unique.pot

The above is working absolutely fine apart from these 2 things in order of difficulty to overcome:

  1. Throughout all the website source code I’ve been careful to ensure all the strings which need translating are surrounded by the function _( ‘string to translate here’ ), but the xgettext command is extracting pretty much every string in the file from what I can tell, not just the ones surrounded by the _(”) function. This means my resulting .pot file contains variable names, URL’s, format strings, function parameters, configuration data and other inappropriate strings which should not be passed onto our translators. Due to the size of the website it isn’t practical to manually remove these – we’re looking at nearly 80,000 string entries and this is just the first website of a number I’ll need to process in the same way within the next 6 weeks! How can xgettext be configured to only extract the strings intended for translation?

  2. A lot of the strings extracted have line breaks in them, which are inserted as \n within the strings. Is there some way to configure xgettext to not do this, or an easy way to remove these?

I’ve been reading through the documentation and searching the web for hours even days trying to find a solution particularly to problem no. 1, and would really appreciate some help from the gettext gurus! Thanks in advance..

  • 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-05-22T12:46:12+00:00Added an answer on May 22, 2026 at 12:46 pm

    Just guessing here, but the first issue you are experiencing might be caused by the -a option. From the xgettext manual:

    -a, --extract-all           extract all strings
    

    As a side note, your xgettext invocation seems quite complex. I, of course, don’t known exactly what you want to do, but for me the following command is sufficient:

    xgettext -L PHP --from-code=utf-8 *.php -o messages.pot
    

    This will save all _() enclosed strings into messages.pot.

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

Sidebar

Related Questions

Hey, I'm really struggling with this one. I'am trying to port a small piece
I've been struggling with this one for a couple of days now. My current
For some reason I'm really struggling with this. I'm new to wpf and I
I'm really struggling with grasping how to effectively use FasterCSV to accomplish what I
I'm new to LaTeX and I must say that I am really struggling with
I'm really struggling to decrypt a given cipher text in PHP and I'm hoping
I am tearing my hair out over this one. What tools do people use
I am struggling with this. I have a value in seconds that I want
Really simple question - how do I do a search to find all records
Really stuck on trying to write code to unzip a file or directory on

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.