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

Translations are not loaded from composer repository #2120

Closed
yol opened this issue Aug 4, 2019 · 8 comments
Closed

Translations are not loaded from composer repository #2120

yol opened this issue Aug 4, 2019 · 8 comments
Assignees
Labels
bug Verified issues on the current code behavior or pull requests that will fix them waiting for info Issues or pull requests that need further clarification from the author

Comments

@yol
Copy link

yol commented Aug 4, 2019

Describe the bug
The documentation says that when using composer and requiring codeigniter4/translations, the translations should be automatically picked up and that there is no need to copy them to the app directory.
This does not currently work unfortunately.

CodeIgniter 4 version
4.0.0-beta4

Affected module(s)
language, autoloader

Expected behavior, and steps to reproduce if appropriate

  • Make new composer installation and require codeigniter4/translations
  • Set default locale to anything other than English
  • In the demo controller, try for example var_dump(lang('Validation.noRuleSets'))
  • It will display the English message.

The cause is that the Language module tries to look up the file Language/{$locale}/{$file}.php, but the translations composer repository registers the Translations namespace as the Language directory, which means that codeigniter will try to look for Translations/Language/{$locale}/{$file}.php in the package. The correct file would be Translations/{$locale}{$file}.php. Adjusting the path that is looked up to {$locale}/${file}.php does allow it to work, but it breaks the look-up inside the application and is of course not the real solution (no idea how to solve this cleanly).

Context

  • OS: Linux
  • Web server lighttpd 1.4.54
  • PHP version 7.3.6
@jim-parry
Copy link
Contributor

oops! I cn fix this next week, when I am vack from vacation :-/

@jim-parry jim-parry self-assigned this Aug 10, 2019
@jim-parry jim-parry added bug Verified issues on the current code behavior or pull requests that will fix them in progress labels Aug 10, 2019
@jim-parry
Copy link
Contributor

Corrected the composer autoload config in the translations repo.
You should be able to do a composer update in your project now, and have the translations properly detected.
Can you confirm? Thanks.

@jim-parry jim-parry added waiting for info Issues or pull requests that need further clarification from the author and removed in progress labels Aug 14, 2019
@yol
Copy link
Author

yol commented Aug 15, 2019

Unfortunately, composer version 4.0.0-beta.4 does not seem to contain the fix. I think you may have released the wrong commit?

@jim-parry
Copy link
Contributor

Hmm - I see that. I re-released beta.4, but the binaries were not updated.
I have made a new beta.5 for the translations repo only, which will hopefully correct this :-/

@jim-parry
Copy link
Contributor

Not hearing anything contrary in 4 days, I presume the fix works.

@yol
Copy link
Author

yol commented Aug 20, 2019

No, it does not seem to work. As far as I can tell, the namespace you put into the composer.json is irrelevant for the lookup actually. Did it work on your end?

@jim-parry jim-parry reopened this Aug 20, 2019
@jim-parry
Copy link
Contributor

Gah - I thought it worked for me. WIll recheck :-/

@jim-parry jim-parry added this to the 4.0.0-rc.2 milestone Sep 8, 2019
@jim-parry
Copy link
Contributor

Finally nailed this, as far as I can tell.
Nothing to change inside the CodeIgniter4 repo, only the composer.json in codeigniter4/translations.
I moved the translations to their own namespace, rather than trying to map them inside the CodeIgniter one; CI's Autoloader "conveniently" strips the CodeIgniter namespace(s) from the composer autloaded set, since it is loaded earlier. Arghhh.
I tested this on a fresh download of the appstarter, then composer required codeigniter4/translations, and joy ensued :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Verified issues on the current code behavior or pull requests that will fix them waiting for info Issues or pull requests that need further clarification from the author
Projects
None yet
Development

No branches or pull requests

2 participants