laravel-localization-loader icon indicating copy to clipboard operation
laravel-localization-loader copied to clipboard

Can't use class constants in the messages.php file

Open wijourdil opened this issue 6 years ago • 3 comments

Hi ! The plugin works like a charm ! But I can't use class constants in the translations files, for example :

'status' => [
    MyClass::STATUS_WAITING => 'Lorem Ipsum',
    MyClass::STATUS_DONE => 'Dolor sit amet',
    ...,
]

I get the following error :

Module build failed: Error: Unexpected PHP key: "staticlookup

wijourdil avatar Jun 11 '18 12:06 wijourdil

That's an interesting case. Not sure how easy will be to solve this case using JS.

rmariuzzo avatar Jun 11 '18 13:06 rmariuzzo

Hi @rmariuzzo,

In order to address this kind of issue you have to scan and index class constants from every php into the repository, and also resolve the use statement in order to have a fully qualified class name (by resolving for example aliases).

I've tried something here : https://github.com/glayzzle/php-reflection but the library is not finished. You can maybe reuse some parts of code.

Best Regards, Ioan

ichiriac avatar Aug 15 '18 17:08 ichiriac

@ichiriac that sound interesting, will take a look. I appreciate the details to avoid common pitfalls.

rmariuzzo avatar Aug 15 '18 22:08 rmariuzzo