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

[Bug] Published lang files are not found #14

Open
realtebo opened this issue Jun 14, 2022 · 0 comments
Open

[Bug] Published lang files are not found #14

realtebo opened this issue Jun 14, 2022 · 0 comments

Comments

@realtebo
Copy link

Bug report

What I did

I created an addon, then published lang files from my addon

What I expected to happen

I expetected to override some strings and see changes in the UI

What happened

Changes are ignored

What I've already tried to fix it

I changed AutomaticServiceProvider as follows

protected function publishedLangsPath() {
    app()->langPath(). '/vendor/'. $this->vendorNameDotPackageName();
}

I don't like it, because, publish lang files, creates a weird folder 'company_name.package_name' instead of standard 'company_name' .

It's ugly but laravel 9 can find it.

See vendor/laravel/framework/src/Illuminate/Translation/FileLoader.php , in the specific note the inner working of

  • loadNamespaced
  • loadNamespaceOverrides

I've no idea how to add additional overrides or hints from the package itself to be able to autopublish to a company_name folder instead of company_name.package_name and ALSO allow Laravel to find overrides in here.

i tried also to leave publishedLangsPath as

return app()->langPath(). '/vendor/'. $this->vendorName;

but change boot()

from

    if ($this->packageDirectoryExistsAndIsNotEmpty('resources/lang')) {
        $this->loadTranslationsFrom($this->packageLangsPath(), $this->vendorNameDotPackageName());
    }

to

    if ($this->packageDirectoryExistsAndIsNotEmpty('resources/lang')) {
        $this->loadTranslationsFrom($this->packageLangsPath(), $this->vendorName);
    }

This causes the desidered folder name, with only the company, but then every occurrency of

trans('company_name.package_name::package_name.string_key') 

must be replaced with

trans('company_name::package_name.string_key') 

Context to replicate the bug - Backpack, Laravel, PHP, DB version

When I run php artisan backpack:version the output is:

### PHP VERSION:
PHP 8.0.3 (cli) (built: Mar  2 2021 23:34:05) ( ZTS Visual C++ 2019 x64 )
Copyright (c) The PHP Group
Zend Engine v4.0.3, Copyright (c) Zend Technologies

### LARAVEL VERSION:
v9.17.0@091e287678ac723c591509ca6374e4ded4a99b1c

### BACKPACK VERSION:
5.1.0@9e1de794137ceb1ade1fa35e3b9366f97285efb3
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

No branches or pull requests

1 participant