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
[BUG] When exporting as JSON, keys containing a dot (.) are converted it into nested objects. #1410
Comments
Hello, Thanks for letting us know! First of all, the approach Laravel people suggest we consider the bad practice. This naming can lead to reusing the same keys in different contexts, which can lead to wrong translations. For example key "Close" can be translated as "Dismiss" in one context and "Near" in another. Perfect localization is crucial for Tolgee, and similar practices can cause a lot of trouble in the future. If you don't want to invent the keys, you can generate a random UUID as a key name. You can modify the current exporting behavior if you use the export endpoint. https://tolgee.io/api#tag/Export/operation/export_1 Using GET
This makes it return the files you desire. Notice that this parameter will be renamed Anyway, it's not a bug, and the JSON we return is perfectly valid. It's just how Tolgee works and what's how Tolgee expects the files to look in its native integrations. |
Please add the relevant information into the docs. |
Feel free to submit PR to docs repository . Otherwise, we will provide better docs for other than JS technologies with All format support, which is on our roadmap |
This query param doesn't seem to work with this API: |
Yeah, you should use |
The problem is that this endpoint returns a zip file. I cannot use it in my app where I need a JSON response from API. |
still issue, old api is ok:
new api is "broken"
|
Are you using v3.alpha version? |
Which is test endpoit for v3? I tested: |
V3 is isn't released yet. Will be released on 11th January. |
And some endpoit for test? For my issue |
There is currently no test endpoint. |
Ok, we hope, that it will be functional. :) In future, is good point of test endpoit for devs. |
We should have to deprecate the old endpoint at first and remove it later. So there wasn't the need to switch immediately. Next time we will do a better job. ⛳ |
You can easily spin up a test instance on your local machine via Docker as well. v3.0.0-alpha5 images are available for use (and do have the |
According to the IETF JSON RFC, essentially any string of Unicode characters may be a key in a JSON. There are no rules as to the special interpretation of a key that contains a dot (.) character as a shorthand to a nested object or any other such thing.
One of the most popular web frameworks, Laravel, allows and suggests the use of translation strings as keys:
This results in code that's much easier to read and maintain:
Instead of:
When importing a JSON file with such key:value entries into Tolgee it works fine. Take, for instance, this Spanish .json:
Imports correctly:
Now, if we export the Spanish translation through the export tool as .json, we get the following output:
Why? Because Tolgee interprets the
.
at the end ofI love programming.
as a reference to a nested object.Please either bring the JSON export functionality in line with the IETF RFC or give us the option as to how to interpret the dots in the JSON keys for those who rely on such exports.
The text was updated successfully, but these errors were encountered: