Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement custom translation layer #673

Merged
merged 3 commits into from
May 29, 2023
Merged

Implement custom translation layer #673

merged 3 commits into from
May 29, 2023

Conversation

shalvah
Copy link
Contributor

@shalvah shalvah commented May 27, 2023

Translations should work correctly onLaravel 8,9 and 10 now.

To publish translations, run php artisan vendor:publish --tag="scribe-translations". This will create the file resources/lang/scribe.php (or lang/scribe.php).

This may be a bit of a minor breaking change to the previous translation system—they will be ignored. I would recommend deleting any previously published Scribe translations (the en.json file).

The new system is:

  • PHP-based, not JSON-based. Easier to manage.
  • independent of locale. Just edit the published file as you like. If you want to use Scribe's default for certain strings, you can just delete them from your published file.
  • (TO-DO) safer. If a translation string is not found, it will raise an error, rather than print the raw scribe:: string. That way users don't get unexpected text in their docs.

@ccec1t91077
Copy link
Contributor

ccec1t91077 commented May 29, 2023

I've tested localization branch in Laravel 8 and 10 clean project, works fine. :D

Testing process

  1. composer require --dev knuckleswtf/scribe:dev-localization
  2. php artisan vendor:publish --tag=scribe-config
  3. Setup .env
  4. php artisan scribe:generate
  5. Check docs
  6. php artisan vendor:publish --tag="scribe-translations"
  7. Modify lang/scribe.php
  8. php artisan scribe:generate
  9. Check docs

Extra

I've also tested on my current project in development, works fine, too.

@shalvah
Copy link
Contributor Author

shalvah commented May 29, 2023

Nice, thanks!

@shalvah shalvah merged commit 81614bd into master May 29, 2023
6 checks passed
@shalvah shalvah deleted the localization branch May 29, 2023 15:48
@shalvah shalvah mentioned this pull request May 29, 2023
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants