i18n icon indicating copy to clipboard operation
i18n copied to clipboard

[extract_messages] Strings are overwritten if two keys are the same in two different files

Open jorgecoca opened this issue 6 years ago • 1 comments

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:

  1. Create a file test1.dart with this content:
import 'package:intl/intl.dart';
class Test1 {
  String get hola => Intl.message('hola 1', name: 'hola');
}
  1. Create a file test2.dart with this content:
import 'package:intl/intl.dart';
class Test2 {
  String get hola => Intl.message('hola 2', name: 'hola');
}
  1. Extract the ARB contents
  2. Only one entry will be in the ARB, missing the reference of one of the strings

jorgecoca avatar Aug 09 '19 18:08 jorgecoca

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...

ChiefWiggum avatar Sep 26 '19 12:09 ChiefWiggum