Skip to content

Commit

Permalink
release: 5.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Tienisto committed Nov 28, 2021
1 parent 50037ce commit 30f6161
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 7 deletions.
46 changes: 46 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,49 @@
## 5.5.0

**Namespaces**

Split your translations into different files. Each file represents a namespace:

```
i18n/
widgets/
- widgets.i18n.json
- widgets_fr.i18n.json
dialogs/
- dialogs.i18n.json
- dialogs_fr.i18n.json
```

**Interfaces**

Create common super classes for different nodes. This allows for more type safety. Instead of `List<dynamic>`, we can have `List<PageData>`

```json
{
"pages": [
{
"title": "E2E encryption",
"content": "Your data is safe!"
},
{
"title": "Sync",
"content": "Synchronize all your devices!"
}
]
}
```

With the generated mixin:

```dart
mixin PageData {
String get title;
String get content;
}
```

See updated README for further information about those features.

## 5.4.0

- feat: add default plural resolvers for Spanish, French and Italian (Thanks to @SimoneBressan)
Expand Down
24 changes: 19 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ It is recommended to add `fast_i18n` to `dev_dependencies`.
```yaml
dev_dependencies:
build_runner: any
fast_i18n: 5.4.0
fast_i18n: 5.5.0
```
**Step 2: Create JSON files**
Expand Down Expand Up @@ -322,6 +322,20 @@ i18n/
- dialogs_fr.i18n.json
```
You can also use different folders. Only file names matters!
```
i18n/
widgets/
- widgets.i18n.json
- widgets_fr.i18n.json
dialogs/
- dialogs.i18n.json
- dialogs_fr.i18n.json
```
Now access the translations:
```dart
// t.<namespace>.<path>
String a = t.widgets.welcomeCard.title;
Expand Down Expand Up @@ -432,8 +446,8 @@ Often, multiple maps have the same structure. You can create a common super clas
```

Here we know that all objects inside `whatsNew` have the same attributes.
We also know that `firstPage` and all children in `pages` have common attributes.
Let's create 2 interface `PageData` and `NewsData`.
We also know that `firstPage` and all children of `pages` have common attributes.
Let's create 2 interfaces `PageData` and `NewsData`.

```yaml
# File: build.yaml
Expand Down Expand Up @@ -488,15 +502,15 @@ mixin PageData {

Config|Type|Description
---|---|---
`paths`|`List<String>`|List of paths, this interface will be applied; `.*` is allowed at the end
`paths`|`List<String>`|List of paths; Use `.*` to target all children of a node (non-recursive)
`attributes`|`List<String>`|List of attributes

Mode|Description
---|---
single path|Syntax: `<interface>: <path>`; attributes will be detected automatically
`paths` only|For multiple nodes; Attributes will be detected automatically
`attributes` only|All nodes satisfying `attributes` will get the interface.
both|Specified nodes will get the interface containing the specified attributes
both|Specified nodes will get the interface with the specified attributes

### ➤ Locale Enum

Expand Down
2 changes: 1 addition & 1 deletion pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ packages:
source: hosted
version: "4.0.0"
collection:
dependency: transitive
dependency: "direct main"
description:
name: collection
url: "https://pub.dartlang.org"
Expand Down
3 changes: 2 additions & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: fast_i18n
description: Localization / Internationalization (i18n) solution. Use JSON or YAML files to create typesafe translations via source generation.
version: 5.4.0
version: 5.5.0
homepage: https://github.com/Tienisto/flutter-fast-i18n
publish_to: https://pub.dev

Expand All @@ -11,6 +11,7 @@ dependencies:
flutter:
sdk: flutter
build: ^2.1.1
collection: ^1.15.0
glob: ^2.0.2
yaml: ^3.1.0

Expand Down

0 comments on commit 30f6161

Please sign in to comment.