Closed
Description
When I generate JS translation files, I cannot use it because I have duplicate keys.
For instance, if I have 2 different translations ids like Error
and Error.
in my translation files, it generates the same key in JS file as ERROR
so I have it twice in my translation file and I cannot build my JS files
The problem comes from the TranslationsDumper
class which using translation id
instead of constant name
in getTranslations
method
The id
should be the final constant name
to exclude duplicate keys instead of the translation id like below
$constantName = s($id)->ascii()->snake()->upper()->toString();
$translations[$constantName] ??= [];
$translations[$constantName][$realDomain] ??= [];
$translations[$constantName][$realDomain][$locale] = $message;
Hope this is clear for everyone