Leaving the replace_breaks option enabled double-escapes line breaks in JSON export
Haraldson opened this issue · comments
Describe the bug
As per the documentation: replace_breaks
: Enable to replace line breaks in exported translations with \n
. Default: true
. Instead, when I leave this option on, what I get is \\n
, which then outputs actual ‘\n’s to the user, instead of a line break as intended.
To Reproduce
Including all my options in case any of them affects this in any way;
lokalise.files.download(<projectId>, {
format: 'json',
original_filenames: false,
bundle_structure: '%LANG_ISO%.%FORMAT%',
all_platforms: true,
add_newline_eof: true,
export_sort: 'a_z',
export_empty_as: 'base',
plural_format: 'icu',
icu_numeric: true,
placeholder_format: 'icu',
indentation: '4sp'
})
Expected behavior
I expect line breaks added with Shift+Enter in the translation UI to appear as \n
, instead they’re double-escaped to \\n
.
If I instead specify replace_breaks: false
in the options object, I get the desired result – but it feels accidental.
Your environment:
- Node version: v12.16.3
Is this because line breaks aren’t supported in JSON, and so they are replaced implicitly no matter what the option is set to? If that’s the case, should this then be documented?
Hello! I believe, this is not directly related to the Node SDK itself... @beinarovic Would you kindly check if that's an expected behaviour?
Okay, so actually this replace_breaks
option should not have any effect for certain formats like JSON. It is not even present in the UI for JSON: https://i.imgur.com/G0cXam1.png Thing is, there's a bug with the API which enables replace_breaks
by default for all formats even if that's not needed. Therefore, for now you can set this option to false
manually, and meanwhile we will fix this problem.