Closed lohnn closed 7 months ago
I cannot reproduce this error. Be aware that JSON supports \n
natively so you might accidentally escape this as an input to the overrides
I could try to create a minimal reproducible repo and link it here if it would help? :)
What file type do you use? I can see inconsistencies when parsing YAML (\n
are lost) and CSV (\n
are escaped)
I've tested using JSON as well as using overrideTranslationsFromMap
, which takes a Dart map.
overrideTranslationsFromMap
works on my side.
import 'package:example/i18n/strings.g.dart';
void main() {
final s1 = t.customerService.openHours;
print(s1);
print('------');
final translation = {
'customerService': {
'title': 'Customer service',
'openHours': 'Office111: Week days 7-23\nChat: All days 8-23',
},
};
LocaleSettings.overrideTranslationsFromMap(
locale: AppLocale.en,
isFlatMap: false,
map: translation,
);
final s2 = t.customerService.openHours;
print(s2);
}
prints
Office: closed
Chat: All days 8-23
------
Office111: Week days 7-23
Chat: All days 8-23
Hmm, testing this in a self-contained example, it seems to work. I'll check a bit more and see if I can figure out what's what and get back to you!
You know what?! It seems to have been fixed between the version that we apparently ran (and I totally forgot to update - slang: ^3.22.0) and the current version. It is now working perfectly as intended.
I apologise for wasting your time and thank you very much for looking at it.
Closing due to PEBCAK.
Describe the bug We have a few texts in the app that are multi-line. Generating and using them works fine in the app. When we try to override the translation to update the text, the new-lines are escaped out and shows up as literal \n.
To Reproduce Steps to reproduce the behavior:
Properly generated code works as expected:
Overriding text escapes the newlines
\n
:The same issue occurs for both
LocaleSettings.overrideTranslations
andLocaleSettings.overrideTranslationsFromMap
Expected behavior Newlines show up as expected in the app, such as: