-
Notifications
You must be signed in to change notification settings - Fork 62
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
Does it even work with JSON object messages? #69
Comments
I'm not a Javascript developer, your package seems to be the only "working" one, so please keep it up to date. |
This snippet is a life saver, finally got it working with Let me share the Laravel-end for future-comers. P.S: I am not sure if this is the most efficient way but works so far :)
|
Great job as well, thanks mate! |
Hello @OzanKurt, it is possible that it has been difficult for you to navigate different levels of an object and that's why he did it type Chain "language.property" (it's just a speculation) but seeing this I think it would be good a PR in this part and Talk to see if it is feasible. |
I was also looking for a way to use translation strings as key (https://laravel.com/docs/7.x/localization#using-translation-strings-as-keys). As the OP has explained, the _parseKey seems to not care about this scenario. So if I have the following language key
The expected result when I run the following is But the _parseKey method instead attempts to find the key 'es.Hello' which of course does not exist. Since laravel's JSON translation files are only 1 level deep, my solution was to alter _getMessage() like the following
This code has worked for me when I load the JSON translation to the root like so:
I am providing an English version of the JSON file as the key itself is the valid English translation. Added a PR here #83 |
I tried:
It parses keys to be flattened like this:
de.No
and then, of course, it cannot find the key.Then I flattened my messages object to be so:
and it worked.
What is the point of this approach? Why would I need to loop through all my language keys and flatten them?
Since Laravel provided us JSON translations, you should make a configuration option for that.
I believe the code above is pretty self-explanatory.
The text was updated successfully, but these errors were encountered: