i18n
i18n copied to clipboard
[extract_messages] Strings are overwritten if two keys are the same in two different files
As a developer, it is my expectation that, if intl can extract strings and add them to an ARB file, it would either fail if two keys are the same, but registered in different files.
Steps to reproduce:
- Create a file
test1.dartwith this content:
import 'package:intl/intl.dart';
class Test1 {
String get hola => Intl.message('hola 1', name: 'hola');
}
- Create a file
test2.dartwith this content:
import 'package:intl/intl.dart';
class Test2 {
String get hola => Intl.message('hola 2', name: 'hola');
}
- Extract the ARB contents
- Only one entry will be in the ARB, missing the reference of one of the strings
We've experienced the same issue. Ideally the extract_to_arb would allow us to generate the names based on the class file and the method name. This would result in your case in a Test1_hola and a Test2_hole. Maybe it's possible to use a converter when calling extract_to_arb, but I haven't figured out yet if it's possible...