[PR #1749] [MERGED] Add ability to override translations with custom text #5886

Closed
opened 2026-02-05 10:19:29 +03:00 by OVERLORD · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/BookStackApp/BookStack/pull/1749
Author: @ssddanbrown
Created: 10/26/2019
Status: Merged
Merged: 10/26/2019
Merged by: @ssddanbrown

Base: masterHead: translation_overrides


📝 Commits (2)

  • e443b42 Made it possible to override translations via theme system
  • 36ea5d5 Added test to check custom theme lang items

📊 Changes

4 files changed (+95 additions, -2 deletions)

View changed files

📝 app/Config/app.php (+1 -2)
app/Providers/TranslationServiceProvider.php (+21 -0)
app/Translation/FileLoader.php (+30 -0)
tests/ThemeTest.php (+43 -0)

📄 Description

Related to #406, Although does not close it outright.

This pull request adds the ability to override existing text translation content with custom values via the theme system (#652).

How to configure

  1. Create a custom theme folder within the existing themes/ directory.
    • For example themes/awesome_theme
  2. Within your .env folder set a APP_THEME variable with the value matching your custom theme folder name.
    • For example APP_THEME=awesome_theme
  3. Add some language content within your theme folder within a lang folder.
    • This folder mirrors the default structure of the BookStack resources/lang/ folder.
    • For example, I can create themes/awesome_theme/lang/en/entities.php, Adding in the content below:
     <?php
     return [
         'books' => 'Sandwiches',
     ];
    
  4. The new translations will now be used first instead of default BookStack translations.

Things to note

  • Translations will fall back to default BookStack translations, so you only need to define translations you want to customize, you don't need to copy all of them out.
  • Changes may be made within the BookStack project to translations so you may need to double check things upon updating as custom overrides may become outdated.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/BookStackApp/BookStack/pull/1749 **Author:** [@ssddanbrown](https://github.com/ssddanbrown) **Created:** 10/26/2019 **Status:** ✅ Merged **Merged:** 10/26/2019 **Merged by:** [@ssddanbrown](https://github.com/ssddanbrown) **Base:** `master` ← **Head:** `translation_overrides` --- ### 📝 Commits (2) - [`e443b42`](https://github.com/BookStackApp/BookStack/commit/e443b424533ed3a3a58a714f398bca4793b5c468) Made it possible to override translations via theme system - [`36ea5d5`](https://github.com/BookStackApp/BookStack/commit/36ea5d544e6dc06f516f0fef2882228a1b8bb1ad) Added test to check custom theme lang items ### 📊 Changes **4 files changed** (+95 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `app/Config/app.php` (+1 -2) ➕ `app/Providers/TranslationServiceProvider.php` (+21 -0) ➕ `app/Translation/FileLoader.php` (+30 -0) ➕ `tests/ThemeTest.php` (+43 -0) </details> ### 📄 Description Related to #406, Although does not close it outright. This pull request adds the ability to override existing text translation content with custom values via the theme system (#652). ### How to configure 1. Create a custom theme folder within the existing `themes/` directory. - For example `themes/awesome_theme` 2. Within your `.env` folder set a `APP_THEME` variable with the value matching your custom theme folder name. - For example `APP_THEME=awesome_theme` 3. Add some language content within your theme folder within a `lang` folder. - This folder mirrors the default structure of the BookStack `resources/lang/` folder. - For example, I can create `themes/awesome_theme/lang/en/entities.php`, Adding in the content below: ```php <?php return [ 'books' => 'Sandwiches', ]; ``` 4. The new translations will now be used first instead of default BookStack translations. ### Things to note * Translations will fall back to default BookStack translations, so you only need to define translations you want to customize, you don't need to copy all of them out. * Changes may be made within the BookStack project to translations so you may need to double check things upon updating as custom overrides may become outdated. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
OVERLORD added the pull-request label 2026-02-05 10:19:29 +03:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#5886