Skip to content

Commit

Permalink
Importer library independently available as a standalone package.
Browse files Browse the repository at this point in the history
  • Loading branch information
marcglasberg committed Nov 16, 2023
1 parent 8e1f815 commit a46ac59
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 599 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
## [10.0.0] - 2023/11/16

* Up to version 8.0.0, the i18n_extension package contained the importer library developed by Johann
Bauer. This importer library has been separated and is now independently available as a standalone
package. You can find it at: https://pub.dev/packages/i18n_extension_importer. This new package
offers capabilities for importing translations in both `.PO` and `.JSON` formats.
It also includes the `GetStrings` exporting utility, which is a useful script designed to
automate the export of all translatable strings from your project.

## [9.0.2] - 2023/05/12

* Flutter 3.10 e Dart 3.0.0
Expand Down
38 changes: 24 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[![pub package](https://img.shields.io/pub/v/i18n_extension.svg)](https://pub.dartlang.org/packages/i18n_extension)

# i18n_extension<br>No boilerplate Translation and Internationalization

> IntelliJ plugin that supports this package coming soon:<br>
<a href="https://plugins.jetbrains.com/files/21898/340924/icon/pluginIcon.svg"><img src="https://plugins.jetbrains.com/files/21898/340924/icon/pluginIcon.svg" height="20px" style="position: relative;top: 5px;"/>
https://plugins.jetbrains.com/plugin/21898-marcelo-s-flutter-dart-essentials
Expand Down Expand Up @@ -669,8 +670,8 @@ I18n.observeLocale =

### Importing and exporting

This package is optimized so that you can easily create and manage all of your translations
yourself, by hand.
The `i18n_extension` package is optimized so that you can easily create and manage all of your
translations yourself, by hand.

However, for large projects with big teams you probably need to follow a more involved process:

Expand Down Expand Up @@ -708,11 +709,18 @@ The following formats may be used with translations:

#### Importing

Up to version `8.0.0`, the `i18n_extension` package contained the importer library.
It has now been separated and is now independently available as a standalone package.
You can find it at: https://pub.dev/packages/i18n_extension_importer.

**Note:** Those importers were contributed by <a href="https://github.com/bauerj">Johann Bauer</a>,
and were separated into its own package by <a href="https://github.com/c0dezli>">Xiang Li</a>.

Currently, only `.PO` and `.JSON` importers are supported out-of-the-box.
If you want to help creating importers for any of the other formats above, please PR there.

**Note:** Those importers were contributed by <a href="https://github.com/bauerj">Johann Bauer</a>.
If you want to help creating importers for any of the other formats above, please PR
here: https://github.com/marcglasberg/i18n_extension.
It also includes the `GetStrings` exporting utility, which is a useful script designed to
automate the export of all translatable strings from your project.

Add your translation files as assets to your app in a directory structure like this:

Expand All @@ -728,7 +736,7 @@ app
Then you can import them using `GettextImporter` or `JSONImporter`:

```
import 'package:i18n_extension/io/import.dart';
import 'package:i18n_extension_importer/io/import.dart';
import 'package:i18n_extension/i18n_extension.dart';
class MyI18n {
Expand Down Expand Up @@ -757,17 +765,19 @@ codes, you'll get errors like this: `There are no translations in 'en_us' for "H

**Note:** If you need to import any other custom format, remember importing is easy to do because
the Translation constructors use maps as input. If you can generate a map from your file format, you
can then use the `Translation()`
or `Translation.byLocale()` constructors to create the translation objects.
can then use the `Translation()` or `Translation.byLocale()` constructors to create the translation
objects.

#### The GetStrings exporting utility

An utility script to automatically export all translatable strings from your project was contributed
by <a href="https://github.com/bauerj">Johann Bauer</a>. Simply
run `flutter pub run i18n_extension:getstrings` in your project root directory and you will get a
list of strings to translate in `strings.json`. This file can then be sent to your translators or be
imported in translation services like _Crowdin_, _Transifex_ or _Lokalise_. You can use it as part
of your CI pipeline in order to always have your translation templates up to date.
A utility script to automatically export all translatable strings from your project was also
contributed by <a href="https://github.com/bauerj">Johann Bauer</a>.

Simply run `flutter pub run i18n_extension_importer:getstrings` in your project root directory, and
you will get a list of strings to translate in `strings.json`. This file can then be sent to your
translators or be imported in translation services like _Crowdin_, _Transifex_ or _Lokalise_. You
can use it as part of your CI pipeline in order to always have your translation templates up to
date.

Note the tool simply searches the source code for strings to which getters like `.i18n` are applied.
Since it is not very smart, you should not make it too hard:
Expand Down
3 changes: 1 addition & 2 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,9 @@ linter:
- empty_statements
- hash_and_equals
- implementation_imports
- iterable_contains_unrelated_type
- collection_methods_unrelated_type
- library_names
- library_prefixes
- list_remove_unrelated_type
- no_duplicate_case_values
- overridden_fields
- package_api_docs
Expand Down
10 changes: 5 additions & 5 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
name: i18n_extension
description: Translation and Internationalization (i18n) for Flutter. Easy to use for both large and small projects. Uses Dart extensions to reduce boilerplate.
version: 9.0.2
version: 10.0.0
homepage: https://github.com/marcglasberg/i18n_extension
# author: Marcelo Glasberg <[email protected]>

environment:
sdk: '>=2.19.0 <4.0.0'
sdk: '>=3.0.0 <4.0.0'

dependencies:
sprintf: ^7.0.0
args: ^2.3.1
args: ^2.4.2
equatable: ^2.0.5
intl: ^0.18.0
flutter:
sdk: flutter

dev_dependencies:
analyzer: ^5.3.1
gettext_parser: ^0.2.0
flutter_test:
sdk: flutter
test: ^1.24.9


37 changes: 0 additions & 37 deletions test/getStrings/getstrings.dart

This file was deleted.

137 changes: 0 additions & 137 deletions test/getStrings/i18n_getstrings.dart

This file was deleted.

66 changes: 0 additions & 66 deletions test/getStrings/io/export.dart

This file was deleted.

Loading

0 comments on commit a46ac59

Please sign in to comment.