1

I want to change the default search box placeholder text by using a translation file - it's the text that says "Search entire store here...". I want to change it to "Search website".

I have tried doing this with a translation file at app/design/frontend/<package>/<theme>/i18n/en_US.csv with the following content:

"Search entire store here...", "Search website"

And then I completely cleared the cache and static view files (we are running in developer mode). However, the original placeholder text remains and i've not found a way to change it.

I have also tried adding the translation to app/design/frontend/<package>/<theme>/Magento_Search/i18n/en_US.csv and this also had no effect.

We are running Magento version 2.3.5-p1.

Where do I need to add the translation file to change the search box placeholder text?

2 Answers 2

0

Try changing from.mini.phtml file from below link app/design/frontend/Theme_Vendor/Theme_Name/Magento_Search/templates/

0

Don't try to override the form.mini.phtml file. Since elasticsearch is now baked into Magento (as of 2.3 IIRC), overriding this template causes the autocomplete styling to break. The correct way to update this text is to override the i18n file for your theme. The translation file should be placed at app/design/frontend/VENDOR/THEME/i18n/LOCALE.csv, where VENDOR and THEME are based on your current theme, and LOCALE is the locale for the translation file.

The actual translation file is a CSV, where the first column is the value found the the scripts (usually a direct match the the english version of the string), and the second column is what you want to be displayed in that location for the given local.

I'm guessing the reason you are not seeing your translation being used is because your store is set to use a different locale. Personally, my site is set up with the en_CA locale, so my translation file is en_CA.csv.

Once the file has been created and placed into the path mentioned above, you will need to clear the Magento cache. This can be done via the admin, or by running php bin/magento cache:flush. Once the cache has been flushed, you should see your new translation in effect (assuming no other caching such as Varnish).

If the translation is not being used, ensure the file name matches the default locale for your store.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.