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

Fix issues loading translations #391

Merged
merged 2 commits into from
Aug 24, 2023
Merged

Conversation

leandrogehlen
Copy link
Contributor

No description provided.

@tobias-grasse
Copy link
Contributor

tobias-grasse commented Aug 23, 2023

@bkintanar This looks like a nice addition. Any reasons to not merge this?

As far as I know, all frontend fields use the Vue translation helpers. Loading translations from a vendor-override location would enable users to keep translations for advanced-nova-media-library separate from their other lang files. Giant JSON files tend to become messy string graveyards otherwise 😄
The approach in this PR is similar to how Nova itself does it (vendor/laravel/nova/src/NovaServiceProvider.php::registerResources). I'd suggest using lang_path instead of resource_path('lang/') though, this helper is available in laravel/framework 8.x and up.

protected function loadTranslations()
{
$this->loadJSONTranslationsFrom(__DIR__ . '/../resources/lang');
$this->loadJSONTranslationsFrom(resource_path('lang/vendor/advanced-nova-media-library'));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use lang_path('vendor/advanced-nova-media-library') instead of resource_path('lang/vendor/advanced-nova-media-library'), as users might have configured a different path for their translations.

$locale = $this->app->getLocale();

Nova::translations(__DIR__ . "/../resources/lang/{$locale}.json");
Nova::translations(resource_path("lang/vendor/advanced-nova-media-library/$locale.json"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use lang_path('vendor/advanced-nova-media-library') instead of resource_path('lang/vendor/advanced-nova-media-library'), as users might have configured a different path for their translations.

@bkintanar bkintanar merged commit 83b8410 into ebess:master Aug 24, 2023
Gompje pushed a commit to DaktaDeo/advanced-nova-media-library that referenced this pull request Mar 29, 2024
* Fix issues loading translations

* Replace `resource_path` by `lang_path`
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.

3 participants