Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

PHP / Laravel Localization Example

Demonstrates localizing PHP language files with the Lingo.dev CLI (@lingo.dev/cli) push/pull flow. Covers two formats: Laravel-style lang/*.php arrays and a gettext .po catalog.

Full walkthrough: lingo.dev/en/guides/web-app

What's inside

  • lang/en/*.php — Laravel language files (<?php return [ … ];)
  • lang/en.po — gettext PO catalog
  • .lingo/config.json — Lingo.dev CLI configuration (php and po formats)

Laravel files return a keyed array; only the string values are translated:

<?php

return [
    'nav' => ['dashboard' => 'Dashboard', 'settings' => 'Settings'],
    'greeting' => 'Welcome back, :name!',
];

Quick start

# 1. Install the CLI (or prefix commands with `npx`)
npm install -g @lingo.dev/cli

# 2. Authenticate and link this repo to your engine
lingo login
lingo link

# 3. Translate changed source into every locale
lingo push --wait

Translations are committed per locale: lang/<locale>/*.php mirrors the English files, and lang/<locale>.po sits next to lang/en.po. This repo ships fully translated. After you edit an English file, lingo push --wait translates only the delta. To bootstrap a brand-new locale, add it to .lingo/config.json and run lingo push --backfill-missing.

How it works

lingo push parses each source file, diffs it against .lingo/lock.json, and translates only the human-readable strings through your linked engine:

  • PHP — only the string values in the returned array change. Keys, nested arrays, the <?php … return prefix, comments, and Laravel placeholders like :name/:attribute are preserved.
  • PO — the msgstr values are translated while each msgid stays as the source key, and the header block is preserved.

Automate in CI (optional)

Want translations on every push or PR without running the CLI yourself? See the CI/CD Workflows guide — the Lingo.dev GitHub App translates automatically once installed. The App reads engineId from the committed .lingo/config.json, so run lingo link and commit the updated file before installing it.

Locales

  • Source: en
  • Targets: es, fr, de

Links

About

Demonstrates localizing PHP (Laravel) and gettext PO files with the Lingo.dev CLI push/pull flow

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages