What is Hardcoded String?
A hardcoded string is user-facing text written directly into code or templates instead of going through the translation layer. To the translation pipeline it does not exist: it never appears in lang files, never reaches translators, and renders in the source language for every user regardless of locale.
Hardcoding is rarely a decision; it accumulates. A button label added during a quick fix, a validation message typed inline, a marketing headline pasted into a Blade view. Each one is invisible until someone browses the app in another language and spots English text in the middle of a translated screen.
In a Laravel app, hardcoded text hides in predictable places: text nodes in Blade views, HTML attributes such as placeholder, title, alt and aria-label, flash messages and validation messages written as literals in controllers and form requests, and strings passed to notifications and mailables. Text inside {{ }} that is already wrapped in __(), @lang or trans_choice() is fine; a bare literal in any of those places is not.
Fixing one is mechanical: choose a key, add the source text to lang/en (a PHP group file or en.json), and replace the literal with a __() call, passing any variable parts as named placeholders instead of concatenating them. The hard part is finding them all, because grep for quoted text drowns in CSS classes, route names and config keys.
Two practices keep it in check. Prevention: treat any quoted user-facing literal in a view or controller as a code-review flag. Detection: scan the codebase for suspect literals, either with pseudo-localization testing or a static scanner. For a single template, the free Blade scanner flags hardcoded text and suggests keys. For a whole project, LangSyncer's Code Scanner scans Blade and PHP files, scores each candidate, and rewrites the approved ones into translation keys.
{{-- Hardcoded: text node, attribute and concatenated variable --}}
<button title="Save your changes">Save changes</button>
<p>Welcome back, {{ $user->name }}!</p>
{{-- Externalized --}}
<button title="{{ __('common.save_hint') }}">{{ __('common.save_changes') }}</button>
<p>{{ __('dashboard.welcome', ['name' => $user->name]) }}</p>
// lang/en/dashboard.php
return ['welcome' => 'Welcome back, :name!'];