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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:26:08+00:00 2026-06-09T15:26:08+00:00

I have a lot of php/html files with many strings that should be internationalized

  • 0

I have a lot of php/html files with many strings that should be internationalized with gettext.
Therefore, I have to go through each file, spot the “message” strings and replace each one by

<?= _("<my string>") ?>

I use vim and would like to setup a shortcut (map) to do it easily in insert mode (With CtrlR for instance).

Do you know how to achieve that ?

  • 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-09T15:26:09+00:00Added an answer on June 9, 2026 at 3:26 pm

    I would use Tim Pope’s wonderful surround plugin to accomplish this.

    Add the following to your ~/.vim/after/ftplugin/php.vim file:

    let b:surround_{char2nr('_')} = "<?= _(\"\r\") ?>"
    

    Now you can select some via visual mode then surround. e.g vitS_
    If you are in insert mode you can surround text via <c-s>_ and you cursor will be inserted in between the double quotes.

    As a bonus if you want to do the delete the surrounding <?= _("<text here>") ?> and only leave <text here> you can add the following to your ~/.vim/after/ftplugin/php.vim as well:

    nmap <buffer> <silent> ds_ ds<dt(%df?[(xds"
    

    Tim Pope has many great plugins I highly suggest you take a look some of them.

    For more help see:

    :h surround
    :h surround-customizing
    :h after-directory
    :h curly-braces-names
    :h b:var
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a PHP file that contains a lot of if and else statements
I have heard a lot that PHP is slow compared other languages. Is the
I have a very large script which contains a lot of php files, so
I have a php web application that uses big cookies to store a lot
Possible Duplicate: php false place in condition I have noticed that a lot of
I have several CSS files generated in PHP. I change the current CSS file
Situation: I have many gzipped input files that I want to process in a
I have a lot of html files with custom style sheets within. I would
I have a lot of mp3 files and i stored path of these file
I have a folder with a lot of .php files. I would like to

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.