Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

stach's avatar

LARAVEL TRANSLATIONS LANG NPM ARTISAN

First nothing, my english isn't good... lego

I need help

I Have a problem. I have a site that has everything in English, and I'm changing the files in the /lang/en/ folder for translating for spanish. But when I save, close, and reopen it, the changes aren't saved. The site tells me to run npm install is required, but when I do "npm install" via SSH on hostinger, it tells me this:

-bash: npm: command not found

And if I do it with artisan,

"php artisan npm install"

I get this: ERROR Command "npm" is not defined.

The goal is the following: How can I edit the files and make the changes actually be transmitted? I'm very new to Laravel... maybe it's something easy, but I'm lost. I hope someone understands what I meant to explain.

Thanks.... Greetings, I repeat, I'm very new to both the Laravel language and Laracasts forum's.

1 like
5 replies
JakeMiller's avatar

You don’t need to use npm for this. Just make sure you save your changes correctly and clear the cache. Your translations should appear after that.

2 likes
vincent15000's avatar
  1. Hostinger seems to not allow executing the command npm.

  2. If the language files are PHP files, you don't need to execute npm run build.

  3. php artisan npm install can't work, the artisan command is for Laravel and custom Laravel commands, not for node commands.

  4. Rather than clearing the cache, just cache the files : php artisan optimize.

1 like
stach's avatar

hey @vincent15000, your command optimize works but of a way strange, maybe i need give more details.

i have a restaurant app called foodking, and have settings section where i can find the Lang option, in lang option i have a drop menu where en.json appears for edit it.

next to, i have this text:

  • You do not change any word under the curly bracket text {}. example {name}.
  • When all language is changed then run some command in your terminal or ssh panel.
  • npm install (run just one time)
  • npm run prod

and next the list of all words:

Dashboard: [Escritorio] Site: [Sitio] Name: [nombre] ..... and many much options

your commands, works perfect but for that section of Lang

the dashboard:,site:,name:,etc word was translated in that web section, but where is really needed stay with the dashboard word and not Escritorio word

Now appears like this:

Escritorio: [Escritorio] Sitio: [Sitio] nombre: [nombre] ......

but the MENU where is the word DASHBOARD really isnt have changes.

Dashboard DINING ORDERS POS ITEMS MENU ..... ETC its appearing without changes, without get translated

i dont know if i m doing explain the things good, my english is not good

thanks guys

i.ibb.co/HLR1N0wZ/example.jpg

i have a image for explain better

1 like
vincent15000's avatar

@stach First of all, are you using a frontend like VueJS ? Or the frontend is with Blade ? This will change a lot of things.

If you are using Blade, you need to display the translations with a specific syntax and you don't need to run npm run build.

https://laravel.com/docs/12.x/localization#retrieving-translation-strings

{{ __('messages.welcome') }}

If you are using VueJS, I suggest you to handle translations frontend side and not backend side. And you need to run npm run build.

Then the syntax depends on what package you are using to handle translations. I am using vue-i18n.

https://vue-i18n.intlify.dev/

{{ $t('messages.welcome') }}

And I define the languages in different files in a folder.

import messages from './messages.js';

const languages = {
    en: {
        messages: messages.en,
    },
    fr: {
        messages: messages.fr,
    }
};

export default languages;

The selected language is in a global variable and the translation is immediate when you change the variable value.

<select id="language" v-model="$i18n.locale">
    <option value="en">{{ $t('language.english') }}</option>

    <option value="fr">{{ $t('language.french') }}</option>
</select>

Please or to participate in this conversation.