-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Allow custom key separators for JSON based file formats and exporters. #11390
Allow custom key separators for JSON based file formats and exporters. #11390
Conversation
3fbb0fa
to
cc4c5ac
Compare
05684a2
to
7ea4992
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution, unfortunately I see several issues with it:
- The setting is done at the component level, but doesn't affect file loading when parsing files from the repository. That is confusing.
- When introducing parameters for file formats, we would rather need something more generic, not adding arbitrary parameters for few formats. See Parameters for File formats #1897
- Hard-coding separator to
.
would break YAML as it historically uses->
, see https://github.com/translate/translate/blob/fea03126d2421454bb6d7f029eff2342c681dc30/translate/storage/yaml.py#L32 (I see you've limited this to JSON subclasses only, but this makes the setting behavior inconsistent) - Generally, Weblate preserves whatever is in the file in the round-trip. What is the motivation to add this specific exporter and not just save changed files within Weblate?
Ad 1) When loading from vsc, after setting the source, there should be and option to specify key separator on Ad 2) This is currently rather quick fix, I am planning to add changes to Ad 3) Like I said, it is first step. Ad 4) Unfortunately when some edits are made to the translations, there is no possibility to export changed i18nextv4 translations. JSON and JSON nested formats are stripping out pluras, and i18nextv4 exporter alone will nest keys in resulting JSON regardless whether the dot was inside the key eg. |
You don't need to convert the format via exporters when changing existing i18nextv4 translation. Just download the file as it is. The format exporting is there for interoperability with a few formats, and not as a generic framework for converting anything to anything. |
Unfortunately there is no other way to download only reviewed and accepted translations. Exporters allow for selecting subset of translations without downloading whole file. |
I understand your need, but I see this more like a workaround than a solution.
|
This pull request has been automatically marked as stale because there wasn’t any recent activity. It will be closed soon if no further action occurs. Thank you for your contributions! |
Proposed changes
During discussion in translate/translate#5179 I realized that Weblate during export is losing key structure by not escaping dots in the natural language keys. Instead of escaping and unescaping separators throughout whole application I've implemented support for custom key separator allowing for simple import and export of files containing non-default key separators.
Checklist
Other information
Setting up key separator when creating component from scratch. Option is also available when creating component from other sources as well it is possible to change key separator in component settings.
Have a great day!
Michał Karol