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

error: foreach() argument must be of type array|object, int given on line 139 #2

Closed
ordago opened this issue Feb 21, 2022 · 4 comments

Comments

@ordago
Copy link
Contributor

ordago commented Feb 21, 2022

public function handleFile($languageDir, $langFile)
{
$lines = include($langFile);
$fileName = Str::afterLast($langFile, "/");
foreach ($lines as $index => $line) {

    } catch (\Exception $e) {
        dd([
            '$lines' => $lines,
            '$fileName' => $fileName,
        ]);
    }

I checked the values and got this:

  array:2 [
    "$lines" => 1
    "$fileName" => "C:\[...]\lang\ca.json"
  ]

I didn't pass any argument to the command and it's on a Laravel 9 project with the lang directory in the new place.

@LarsWiegers
Copy link
Owner

Hey!

Thanks for creating the issue.

Did not know that json files were supported for langs. Thanks for that!
The package is still mayor WIP. as you can see in the commits haha.

Most likely the include on the json is failing.

If you want you can create a pr to support json files, or i will take a look at it in the soon future.

Let me know either way please.

@ordago
Copy link
Contributor Author

ordago commented Feb 21, 2022

Some language string need to be on the json files. e.g. The new password rules:

https://laravel.com/docs/8.x/validation#validating-passwords

I was checking the package but I don't currently have time to dig deeper.

For this purpose use BabelEdit

https://www.codeandweb.com/babeledit

@LarsWiegers
Copy link
Owner

hey thanks, for the fast response.

I will definitly check out BabelEdit

@LarsWiegers
Copy link
Owner

So this actually was fixed. as such closing the issue.

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

2 participants