laravel-translation
Manage Laravel translation files in a Google Sheet, with surgical pulls that keep your comments and formatting.
v0.5.1, 1 star, 1 download
Last release
Lines changed:
+14,427 added
−4,751 removed
Install
composer require paper-leaf-tech/laravel-translationFull documentation lives in the README.
Writing about laravel-translation
Changelog
Changelog
All notable changes to laravel-translation will be documented in this file.
Unreleased
[0.5.1] - 2026-11-25
Fixed
- Corrected the author name in
composer.json.
0.5.0 - 2026-10-05
Breaking Changes
- One
Translationstab replaces theTranslations - {locale}tabs. Columns arekey,group,default, the source locale, one column per locale, then any columns you add, found by header name. translations:pushtakes no locale and always writes every locale.--clearand--force-initialare replaced by--fresh.- Config: removed
key_column,original_value_column,updated_value_columnandheader_row; addedsheet,source_localeandformat. - Backups are one JSON file per push in the backup directory instead of one per locale.
Added
- The sheet's English is editable.
defaultholds the English from code as of the last push; when code and the sheet both change a line, push keeps the sheet's text and lists the conflict. - Columns you add to the tab (
status,notes, …) are kept with their row on every push. translations:push --dry-run.- Sheet formatting after each push (frozen header, filter, widths, red empty translations, protected key/group/default), switchable with
TRANSLATION_FORMAT_SHEET. TranslationsPushedevent for app-specific tabs and formatting.source_localeconfig, used by push, pull andtranslations:check.translations:checktreats each JSON key as its own English when there is nolang/{source}.json, the way Laravel renders it.- Laravel 12 and 13 support in the test suite.
Changed
translations:pullexits with a failure when it rejects a value for mismatched:placeholders(the other values are still written).- A malformed
lang/{locale}.jsonnow fails with the file's path instead of being read as empty.
Upgrading
- On 0.4.0, run
php artisan translations:pullso code holds the latest translations. - Upgrade to 0.5.0 and update a published config to the new keys.
- Run
php artisan translations:pushto build theTranslationstab. - Delete the old
Translations - {locale}tabs.
0.4.0 - 2026-10-05
Added
translations:checkcompares each locale with the source locale and fails on missing keys, extra keys or mismatched:placeholders. It covers PHP files (including subdirectories), JSON lines and published package overrides. Pass--allow-missingto fail only on placeholders.
Changed
translations:pullskips rows whose:placeholdersdiffer from the source-locale line in code, with a warning listing each one. Previously such a row was written to the file and silently dropped the replacement at runtime.
0.3.1 - 2026-10-05
Fixed
translations:pullnow writes into translation files in subdirectories. Push flattenslang/{locale}/resources/schools.phpinto keys likeresources.schools.title; pull previously looked forresources.phpand skipped every row. Pull now picks the deepest existing file that matches the key.translations:pushnow clears leftover rows below the data it writes. Previously, removing keys from code left the old trailing rows in the sheet as duplicates, and pull could apply those stale values over the live ones.- The published config no longer references
Google\Service\Sheets::SPREADSHEETS. Apps that installed the package with--devand published the config crashed on boot in production (--no-dev) because the class was missing. If you already published the config, replace that line in yourconfig/laravel-translation.phpwith'https://www.googleapis.com/auth/spreadsheets'.
0.3.0 - 2026-05-08
Breaking Changes
translations:pullno longer regenerates translation files. It now updates existing keys in place using AST manipulation, preserving comments, blank lines, indentation, and quote styles.- Pull will not create files or directories. Running pull against a locale that has no
lang/{locale}/directory yields a "skipped" warning instead of generated files. To bootstrap a new locale, create starter files manually first. - Keys present in the sheet but missing from the local file are skipped with a per-key warning instead of being added. Add the key to the appropriate file in code, then re-pull to populate its value.
- Removed the
__misc.phpfallback for keys without a dot — those keys are now skipped with a warning.
Added
- Surgical pull: comments, blank lines, indentation, and original quote styles in
lang/*.phpfiles are preserved across pulls. - New service
TranslationFileWriter(AST-based vianikic/php-parser). - Per-file pull stats: keys updated, keys skipped (new), keys skipped (non-string values).
Changed
nikic/php-parser ^5.0is now a runtime dependency.
Removed
PullCommand::generatePhpArray()and the file-regeneration code path.PullCommand::writeTranslations()(replaced byapplyUpdates()delegating toTranslationFileWriter).
0.2.0 - 2026-05-08
Breaking Changes
- All env vars renamed:
GOOGLE_SHEETS_*→TRANSLATION_*(TRANSLATION_SPREADSHEET_ID,TRANSLATION_CREDENTIALS_PATH,TRANSLATION_BACKUP_KEEP,TRANSLATION_BACKUP_AUTO_PRUNE). GOOGLE_SHEETS_SHEET_NAMEremoved. Each locale uses its own sheet tab namedTranslations - {locale}(auto-created on push).- Default credentials filename changed from
laravel-translations-account.jsontolaravel-translation-credentials.json. Either rename your file or setTRANSLATION_CREDENTIALS_PATH. - For non-English sheets, Column B is now the English source string (was: the locale's own value). Column C is the translation. Untranslated rows (empty Column C) are skipped on pull instead of falling back to English.
GoogleSheetsServicepublic methods now takestring $sheetNameas the first parameter. Removed:appendSheetData,createBackup,pruneBackups. Thesheet_nameconfig key has been deleted.- Existing in-spreadsheet "Backup YYYY-MM-DD" duplicate sheets are no longer created or pruned. Export anything you want to keep before upgrading.
Added
- Multi-locale push/pull. Running
php artisan translations:pushor:pullwith no argument iterates every locale underlang/. - English-driven Column B for non-source locales — translators see the source string they're translating from.
- Auto-creation of locale sheet tabs when missing.
- Local JSON backups under
storage/app/translation-backups/{locale}/..gitignorewritten automatically on first run. TRANSLATION_BACKUP_PATHenv var; setting it tofalseornulldisables backups entirely.- New services:
TranslationBackupManager,TranslationReconciler. New constants class:TranslationConventions. New trait:Concerns\DiscoversLocales. - Spreadsheet URLs printed after push/pull include
#gid=to deep-link to the locale tab. - Push reports stale-translation count, untranslated count, and target-only-key count for non-source locales.
Removed
- In-spreadsheet duplicate-sheet backups.
GoogleSheetsService::appendSheetData()(was unused).
Considered, deferred
- Switching
addslashes()→var_export()in PHP file generation — current behavior is correct for single-quoted output and a swap risks breaking snapshot-style output without enough benefit at this stage.
0.1.0 - 2026-01-30
Added
- Spreadsheet URL output in push and pull commands for easy access to Google Sheets
- Comprehensive test suite with unit and feature tests
- GitHub Actions workflow for automated testing across PHP 8.2, 8.3 and Laravel 10, 11
- Configuration options for backup functionality (
backup.keepandbackup.auto_prune) - Validation for backup pruning parameters
Improved
- Enhanced backup functionality with better error handling
- Clearer console output for backup operations
- Better exception messages for backup-related errors
- Configuration documentation with backup settings
Changed
- Backup creation now wrapped in try-catch for better error resilience
- Backup pruning now respects configuration values instead of hardcoded defaults
0.0.14 - Previous Release
Changed
- Renamed commands to push/pull
- Various improvements to console messaging
- Don't create empty backups
- Keep original cell values
- Added sheet backups