Docs Translations

Laratic makes it simple to localize your docs. The documentation controller automatically looks for a translation in the active language and falls back to English if one isn’t available.

How Locale Fallback Works

All docs pages are handled by App\Http\Controllers\DocumentationController. When someone visits /docs/{topic}, the controller:

  1. Gets the current locale using app()->getLocale().
  2. Turns the topic (e.g. blog/translations) into a dot-path.
  3. Tries to load resources/views/pages/docs/<locale>/<topic>.blade.php.
  4. If it doesn’t exist and the locale isn’t en, it falls back to the English version under resources/views/pages/docs/en.

For the changelog topic, the lookup order is:

  1. resources/views/pages/docs/<locale>/changelog.blade.php
  2. resources/views/pages/docs/en/changelog.blade.php
  3. resources/views/pages/docs/changelog.blade.php (supported, but not used by default)

Adding a Translation

To add a translated docs page (for example, Spanish es):

  1. Create the locale folder if it doesn't exist: resources/views/pages/docs/es.
  2. Copy the English page into that folder. For example:
    resources/views/pages/docs/en/changelog.blade.phpresources/views/pages/docs/es/changelog.blade.php
  3. Translate the text in the new file while keeping the same layout and Blade components.
  4. Switch the app locale to es, then visit /docs/changelog to see the result.

For example, if you have an English file at:

resources/views/pages/docs/en/documentation/translations.blade.php

The Spanish translation must be at:

resources/views/pages/docs/es/documentation/translations.blade.php

Notice that only en changes to es—the documentation/translations.blade.php part stays exactly the same.