You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am generating multiple arb files (like the example) and for the most part it's working great. I am mainly doing this to be able to split up my translations by feature, which is very cool that it works.
The issue is that if two features have a 'title', that to prevent conflicts I have to prefix the message name with the class name. I'll include an example of the code here:
@GenerateArb(suppressLastModified: true, dir: 'assets/arb')
class DashboardTranslations {
static DashboardTranslations of(BuildContext context) =>
Localizations.of<DashboardTranslations>(context, DashboardTranslations)!;
String get title => Intl.message(
'Dashboard title',
name: 'DashboardTranslations_title',
);
String get hero => Intl.message(
'Build your next idea even faster.',
name: 'DashboardTranslations_hero',
);
}
This does work as expected, the problem is having to type out DashboardTranslations_ for each name, as it's tedious and harder to read.
I'm wondering if we can have an option under GenerateArb to prefix all names with the class name? Perhaps like this:
@GenerateArb(suppressLastModified: true, dir: 'assets/arb', prefixMessageNames: true)
class DashboardTranslations {
That way my message could look like this:
String get title => Intl.message(
'Dashboard title',
name: 'title',
);
This would produce arb like so:
{
"@@locale": "en",
"DashboardTranslations_title": "Dashboard title",
"@DashboardTranslations_title": {
"type": "text",
"placeholders_order": [],
"placeholders": {}
},
"DashboardTranslations_hero": "Build your next idea even faster.",
"@DashboardTranslations_hero": {
"type": "text",
"placeholders_order": [],
"placeholders": {}
}
}
Lastly it would be even better again if I could omit the name and end up with the same arb. The name is pretty much always the same as the getter. I don't know if it would be possible but I would love to write this:
String get title => Intl.message('Dashboard title');
Thank you so much @jaumard for the work you've done on this package by the way, even without the fixes above it's a huge improvement over having one massive file.
The text was updated successfully, but these errors were encountered:
That would let people choose what they want, example if the class name is too long it might not be wanted (even more if you download ARB from the network as it will make it heavier). I didn't check yet but that should be doable!
Lastly it would be even better again if I could omit the name and end up with the same arb. The name is pretty much always the same as the getter. I don't know if it would be possible but I would love to write this:
String get title => Intl.message('Dashboard title');
Unfortunately that's not doable, the way Intl is working make it impossible to not have this I think from memory.
I am generating multiple arb files (like the example) and for the most part it's working great. I am mainly doing this to be able to split up my translations by feature, which is very cool that it works.
The issue is that if two features have a 'title', that to prevent conflicts I have to prefix the message name with the class name. I'll include an example of the code here:
This does work as expected, the problem is having to type out DashboardTranslations_ for each name, as it's tedious and harder to read.
I'm wondering if we can have an option under GenerateArb to prefix all names with the class name? Perhaps like this:
That way my message could look like this:
This would produce arb like so:
Lastly it would be even better again if I could omit the name and end up with the same arb. The name is pretty much always the same as the getter. I don't know if it would be possible but I would love to write this:
Thank you so much @jaumard for the work you've done on this package by the way, even without the fixes above it's a huge improvement over having one massive file.
The text was updated successfully, but these errors were encountered: