Skip to content

Problem with php langs generation #158

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

Closed
rudolfbruder opened this issue Jan 5, 2024 · 6 comments · Fixed by #159
Closed

Problem with php langs generation #158

rudolfbruder opened this issue Jan 5, 2024 · 6 comments · Fixed by #159
Labels
bug Something isn't working

Comments

@rudolfbruder
Copy link

Hi,

I am facing an issue in our project with generation of langs from php files. Our project started out i think on laravel 7 and as the time passed we updated it to 10 as of now.

However we still have langs in 'resources/lang' directory.

When I tried to specify this path as mentioned in docs in mix.i18n("resources/lang") my build crashes with following error:


/var/www/html/node_modules/laravel-vue-i18n/dist/loader.cjs:69
    if (expr.kind === 'string') {
             ^

TypeError: Cannot read properties of undefined (reading 'kind')
    at parseItem (/var/www/html/node_modules/laravel-vue-i18n/dist/loader.cjs:69:14)
    at parseItem (/var/www/html/node_modules/laravel-vue-i18n/dist/loader.cjs:85:12)
    at parseItem (/var/www/html/node_modules/laravel-vue-i18n/dist/loader.cjs:83:36)
    at /var/www/html/node_modules/laravel-vue-i18n/dist/loader.cjs:73:46
    at Array.map (<anonymous>)
    at parseItem (/var/www/html/node_modules/laravel-vue-i18n/dist/loader.cjs:73:32)
    at parseItem (/var/www/html/node_modules/laravel-vue-i18n/dist/loader.cjs:83:36)
    at /var/www/html/node_modules/laravel-vue-i18n/dist/loader.cjs:73:46
    at Array.map (<anonymous>)
    at parseItem (/var/www/html/node_modules/laravel-vue-i18n/dist/loader.cjs:73:32)
    at parseItem (/var/www/html/node_modules/laravel-vue-i18n/dist/loader.cjs:83:36)
    at /var/www/html/node_modules/laravel-vue-i18n/dist/loader.cjs:73:46
    at Array.map (<anonymous>)
    at parseItem (/var/www/html/node_modules/laravel-vue-i18n/dist/loader.cjs:73:32)
    at parse (/var/www/html/node_modules/laravel-vue-i18n/dist/loader.cjs:65:32)
    at /var/www/html/node_modules/laravel-vue-i18n/dist/loader.cjs:121:66
    at Array.forEach (<anonymous>)
    at readThroughDir (/var/www/html/node_modules/laravel-vue-i18n/dist/loader.cjs:114:35)
    at parseAll (/var/www/html/node_modules/laravel-vue-i18n/dist/loader.cjs:41:49)
    at /var/www/html/node_modules/laravel-vue-i18n/dist/mix.cjs:39:141
    at Hook.eval [as call] (eval at create (/var/www/html/node_modules/tapable/lib/HookCodeFactory.js:19:10), <anonymous>:16:1)
    at Hook.CALL_DELEGATE [as _call] (/var/www/html/node_modules/tapable/lib/Hook.js:14:14)
    at /var/www/html/node_modules/webpack/lib/Compiler.js:1168:23
    at Hook.eval [as callAsync] (eval at create (/var/www/html/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:22:1)
    at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/var/www/html/node_modules/tapable/lib/Hook.js:18:14)
    at Compiler.compile (/var/www/html/node_modules/webpack/lib/Compiler.js:1165:28)
    at /var/www/html/node_modules/webpack/lib/Watching.js:218:19
    at Hook.eval [as callAsync] (eval at create (/var/www/html/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:22:1)
    at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/var/www/html/node_modules/tapable/lib/Hook.js:18:14)
    at run (/var/www/html/node_modules/webpack/lib/Watching.js:172:33)
    at /var/www/html/node_modules/webpack/lib/Watching.js:167:6
    at Compiler.readRecords (/var/www/html/node_modules/webpack/lib/Compiler.js:989:5)
    at run (/var/www/html/node_modules/webpack/lib/Watching.js:163:26)
    at Watching._go (/var/www/html/node_modules/webpack/lib/Watching.js:222:3)
    at Watching._invalidate (/var/www/html/node_modules/webpack/lib/Watching.js:423:9)
    at /var/www/html/node_modules/webpack/lib/Watching.js:69:28
    at processTicksAndRejections (node:internal/process/task_queues:78:11)

Got any advice please? If I dont specify the path I see the lang folder beign created during the build / watcher process but as soon as it hits 100% it gets deleted.

Thank you.

@rudolfbruder
Copy link
Author

rudolfbruder commented Jan 5, 2024

I found a problem and it is than in one of our lang files the translation value was set to null? Maybe you could add check in the package for that?

Also I am really interested how does this package work with php file. I could not understand it from the code. But i see files like php_sk.json getting generated but the deleted and it still somehow works. Could you please explain or set me on proper track ?

@xiCO2k
Copy link
Owner

xiCO2k commented Jan 5, 2024

Hey @rudolfbruder thanks for reporting.

was there a translation set to null or an entire object example:

$t('message')

return ['message' => null'];

or is it like this?

$t('parent.message')

return ['parent' => null];

Thanks for the help.

@conturov911
Copy link

conturov911 commented Jan 5, 2024

I have the same error.
In my lang file was line like this:

return [
   'user' => []
];

@xiCO2k
Copy link
Owner

xiCO2k commented Jan 5, 2024

Solved and released on v2.7.5.

Thanks.

@luisprmat
Copy link

@xiCO2k I didn't know where to ask, but I would like to know if I can use this package to export the translations to javascript and be able to use them within an app just built in Vue and your backend is a Laravel API (separated projects) and how to do that?. This package works prefect when the project is integrated in one with inertia vue (breeze or jestream), but if backend and frontend are in separated projects?

@xiCO2k
Copy link
Owner

xiCO2k commented Jan 20, 2024

Hey @luisprmat, an export translation feature is something I'm considering adding to this package.

If you would like to contribute adding this. Go ahead

Thanks for the suggestion

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants