Skip to content

Commit

Permalink
docs: update translation overrides
Browse files Browse the repository at this point in the history
  • Loading branch information
Tienisto committed Jan 2, 2025
1 parent ffa2e35 commit 2b717a6
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion slang/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1156,7 +1156,7 @@ LocaleSettings.overrideTranslations(
content: r'''
onboarding
title: 'Welcome {name}'
'''
''',
);
// access
Expand All @@ -1170,6 +1170,21 @@ A few remarks:
3. New translations will be parsed but have no effect.
4. New parameters stay unparsed. (i.e. `{name}` stays `{name}`)

If you use dependency injection, then you can create a new overridden instance using `AppLocaleUtils`:

```dart
Translations t2 = AppLocaleUtils.buildWithOverridesSync(
locale: AppLocale.en,
fileType: FileType.yaml,
content: r'''
onboarding
title: 'Welcome {name}'
''',
);
String a = t2.onboarding.title(name: 'Tom'); // "Welcome Tom"
```

### ➤ Dependency Injection

You don't like the included `LocaleSettings` solution?
Expand Down

0 comments on commit 2b717a6

Please sign in to comment.