Lang.js
Lang.js copied to clipboard
Incorrect returned value
https://github.com/rmariuzzo/Lang.js/blob/31474a87dc21e4434b66b527d00944c61fc2a13d/src/lang.js#L288
if we have two lines as
'book.btn.finish' => 'Finish Booking',
'book.btn' => 'Book Now',
and request Lang.get('book.btn.finish') then _getMessage returned 'Book Now'
if (message[subKey] && entries.length === 0) {
instead
if (message[subKey] !== undefined) {
solves the problem
Hey @astralo! We need to create a test case we your proposed changes. Thanks for letting me know.
I ran into the similar issue.
Imagine the situation when you validate an input array with the nested fields in Laravel:
$request->validate([
...
'location' => 'array',
'location.city_id' => 'required',
...
]);
To localize the validation messages for both location
and location.city_id
attributes we need to add two translation strings:
// resources/lang/en/validation.php
return [
...
'attributes' => [
...
'location' => 'Location',
'location.city_id' => 'City',
...
],
];
And in this case, if we want to use the validation.php
file as a source for Lang.js, we will get the Location
translation result for the lang.get('validation.attributes.location.city_id')
call (instead of City
).
Any news on this?
@RomeroMsk I will try to revisit it on this weekend.
Bump.
FYI I created a PR that solve this issue: https://github.com/rmariuzzo/Lang.js/pull/74 @astralo
In the meanwhile you can use that fork in package.json:
"lang.js": "https://github.com/alfonsobries/Lang.js#feature/proritize-dot-notations",