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

Incorrect returned value #65

Open
astralo opened this issue Feb 20, 2018 · 7 comments
Open

Incorrect returned value #65

astralo opened this issue Feb 20, 2018 · 7 comments

Comments

@astralo
Copy link

astralo commented Feb 20, 2018

if (message[subKey] !== undefined) {

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'

@astralo
Copy link
Author

astralo commented Feb 20, 2018

 if (message[subKey] && entries.length === 0) {

instead

 if (message[subKey] !== undefined) {

solves the problem

@astralo astralo changed the title Inciorrect returned value Incorrect returned value Feb 20, 2018
@rmariuzzo
Copy link
Owner

Hey @astralo! We need to create a test case we your proposed changes. Thanks for letting me know.

@RomeroMsk
Copy link

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).

@RomeroMsk
Copy link

Any news on this?

@rmariuzzo
Copy link
Owner

@RomeroMsk I will try to revisit it on this weekend.

@RomeroMsk
Copy link

Bump.

@alfonsobries
Copy link
Contributor

alfonsobries commented Dec 26, 2018

FYI I created a PR that solve this issue: #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",

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

4 participants