Miniya Abraham

Miniya Abraham

1611780600

I18n-o-matic Makes Translations Easier in Flutter Apps

i18n-o-matic

i18n-o-matic is a dart package to make translations easier in Flutter apps. It provides the ability to automatically search for translatable strings in the source code and builds translations tables for each language. This approach is inspired by the one used in the Qt framework.

  • 🏖 Painless translation workflow
  • 🔍 Automatic discovery of translatable strings
  • 👩‍💻 Human readable YAML format for translations files
  • #️⃣ Formatable strings for variable substitutions

How it works

i18n-o-matic uses original strings marked as translatable in the source code and use them as as translation keys. The I18nOMatic class replaces each translatable string by the corresponding string of the current language. It is advisable to use English as the reference language of the strings to be translated in the application.

First of all, each source file with translatable strings must import the i18n_omatic package:

import 'package:i18n_omatic/i18n_omatic.dart'; 

Mark strings as translatable

To mark a string as translatable, it must be applied the tr() method provided by i18n_omatic:

String firstString = 'My first string'.tr();
// ...
Text('Share on network'.tr());

When parts of the translatable string are based on external values (aka string interpolation), placeholders in the string can be used with a provided key-value table. These placeholders begins with a % character and must be named with the corresponding key in the table:

String birthdayMsg = 'Happy birthday %name, you are %age years old'.tr({name: 'Peter', age: '21'});

Prepare configuration for translations

Once the strings to translate are marked, you have to create an empty YAML file for each language you want to translate strings into and name it with the “language_country” code (e.g. fr_FR.yaml for France, es_ES.yaml for Spain, …). For Flutter applications, these files must be located in the assets/i18nomatic directory and added in the corresponding section in the pubspec.yaml configuration file.

Example below is the pubspec.yaml section for french and spanish languages, once the files have been effectively created:

flutter:
  assets:
    - assets/
    - assets/i18nomatic/es_ES.yaml
    - assets/i18nomatic/fr_FR.yaml

For iOS, the file ios/Runner/info.plist must be updated to register the supported locales. The CFBundleLocalizations must be added or updated with an array of the supported languages. The example below is an example for french and spanish languages:

<key>CFBundleLocalizations</key>
<array>
    <string>es_ES</string>
    <string>fr_FR</string>
</array>

Automatically build translation tables

The i18n_omatic package provides a command line tool that will scan the source code of the application and search for the translatable strings. Then, it will update the translation files with the found strings. The following command line has to be run in the root directory of the project:

dart pub run i18n_omatic:update

By default, this command line tool wil scan the lib directory recursively, looking for .dart files, and will update the translations files located in the assets/i18nomatic directory.

You can run this tool whenever needed to update the translation tables with the newly translatable strings introduced in your source code. The previously translated string will remain in the translation files.

Enable translations in application

You have to enable the i18n_omatic localization delegate and add the supported locales in your application definition class. Do not forget to add the locale of the translatable strings in your source code, as it can be considered as the default application language (usually en/US).

MaterialApp(
    // ...
    localizationsDelegates: [
      I18nOMatic.delegate,
      GlobalMaterialLocalizations.delegate,
      GlobalCupertinoLocalizations.delegate,
      GlobalWidgetsLocalizations.delegate,
    ],
    supportedLocales: [
      const Locale('en', 'US'),
      const Locale('fr', 'FR'),
      const Locale('es', 'ES'), 
    ],

Once this is done, every string with the .tr() method will be translated if it is available in the target language.

Edit translation files

Given the following part of ource code:

String firstString = 'My first string'.tr();
// ...
Text('Share on network'.tr());
// ...
String birthdayMsg = 'Happy birthday %name, you are %age years old'.tr({name: 'Peter', age: '21'});
// ...
String ingnoredString = 'ignored string';

At the first run of the i18n_omatic:update command line tool, the following file will be generated for the french language (assets/i18nomatic/fr_FR.yaml):

format_version: 1

strings:
  "My first string" : null
  "Share on network" : null
  "Happy birthday %name, you are %age years old" : null

The 3 collected strings are now available for translation but are null by default. You have to edit the file and provide correct translations as follow (example for french):

format_version: 1

strings:
  "My first string" : "Ma première chaîne de caractères"
  "Share on network" : "Partager sur le réseau"
  "Happy birthday %name, you are %age years old" : "Bon anniversaire %name, tu as %age ans"

If you remove one or more translatable string (e.g. firstString in the example above) in a further development and run again the i18n_omatic:update command line tool, these translated strings will not be lost and will be placed in a unused_strings category:

format_version: 1

strings:
  "Share on network" : "Partager sur le réseau"
  "Happy birthday %name, you are %age years old" : "Bon anniversaire %name, tu as %age ans"

unused_strings:
  "My first string" : "Ma première chaîne de caractères"

Once you are sure you will not use these strings anaymore, you can remove them from the yaml files. You are encouraged to clean up these files before releasing a new version of your application.

Known limitations

  • i18n_omatic does not support currently multiline strings

Author

The i18n-o-matic package is developped by Jean-Christophe Fabre.

Download Details:

Author: jctophefabre

Source Code: https://github.com/jctophefabre/i18n_omatic

#flutter #dart #mobile-apps

What is GEEK

Buddha Community

I18n-o-matic Makes Translations Easier in Flutter Apps

Google's Flutter 1.20 stable announced with new features - Navoki

Flutter Google cross-platform UI framework has released a new version 1.20 stable.

Flutter is Google’s UI framework to make apps for Android, iOS, Web, Windows, Mac, Linux, and Fuchsia OS. Since the last 2 years, the flutter Framework has already achieved popularity among mobile developers to develop Android and iOS apps. In the last few releases, Flutter also added the support of making web applications and desktop applications.

Last month they introduced the support of the Linux desktop app that can be distributed through Canonical Snap Store(Snapcraft), this enables the developers to publish there Linux desktop app for their users and publish on Snap Store.  If you want to learn how to Publish Flutter Desktop app in Snap Store that here is the tutorial.

Flutter 1.20 Framework is built on Google’s made Dart programming language that is a cross-platform language providing native performance, new UI widgets, and other more features for the developer usage.

Here are the few key points of this release:

Performance improvements for Flutter and Dart

In this release, they have got multiple performance improvements in the Dart language itself. A new improvement is to reduce the app size in the release versions of the app. Another performance improvement is to reduce junk in the display of app animation by using the warm-up phase.

sksl_warm-up

If your app is junk information during the first run then the Skia Shading Language shader provides for pre-compilation as part of your app’s build. This can speed it up by more than 2x.

Added a better support of mouse cursors for web and desktop flutter app,. Now many widgets will show cursor on top of them or you can specify the type of supported cursor you want.

Autofill for mobile text fields

Autofill was already supported in native applications now its been added to the Flutter SDK. Now prefilled information stored by your OS can be used for autofill in the application. This feature will be available soon on the flutter web.

flutter_autofill

A new widget for interaction

InteractiveViewer is a new widget design for common interactions in your app like pan, zoom drag and drop for resizing the widget. Informations on this you can check more on this API documentation where you can try this widget on the DartPad. In this release, drag-drop has more features added like you can know precisely where the drop happened and get the position.

Updated Material Slider, RangeSlider, TimePicker, and DatePicker

In this new release, there are many pre-existing widgets that were updated to match the latest material guidelines, these updates include better interaction with Slider and RangeSliderDatePicker with support for date range and time picker with the new style.

flutter_DatePicker

New pubspec.yaml format

Other than these widget updates there is some update within the project also like in pubspec.yaml file format. If you are a flutter plugin publisher then your old pubspec.yaml  is no longer supported to publish a plugin as the older format does not specify for which platform plugin you are making. All existing plugin will continue to work with flutter apps but you should make a plugin update as soon as possible.

Preview of embedded Dart DevTools in Visual Studio Code

Visual Studio code flutter extension got an update in this release. You get a preview of new features where you can analyze that Dev tools in your coding workspace. Enable this feature in your vs code by _dart.previewEmbeddedDevTools_setting. Dart DevTools menu you can choose your favorite page embed on your code workspace.

Network tracking

The updated the Dev tools comes with the network page that enables network profiling. You can track the timings and other information like status and content type of your** network calls** within your app. You can also monitor gRPC traffic.

Generate type-safe platform channels for platform interop

Pigeon is a command-line tool that will generate types of safe platform channels without adding additional dependencies. With this instead of manually matching method strings on platform channel and serializing arguments, you can invoke native class and pass nonprimitive data objects by directly calling the Dartmethod.

There is still a long list of updates in the new version of Flutter 1.2 that we cannot cover in this blog. You can get more details you can visit the official site to know more. Also, you can subscribe to the Navoki newsletter to get updates on these features and upcoming new updates and lessons. In upcoming new versions, we might see more new features and improvements.

You can get more free Flutter tutorials you can follow these courses:

#dart #developers #flutter #app developed #dart devtools in visual studio code #firebase local emulator suite in flutter #flutter autofill #flutter date picker #flutter desktop linux app build and publish on snapcraft store #flutter pigeon #flutter range slider #flutter slider #flutter time picker #flutter tutorial #flutter widget #google flutter #linux #navoki #pubspec format #setup flutter desktop on windows

Hire Dedicated Flutter App Developer USA| Flutter App Developers

Hire Flutter App Developers: WebClues Infotech is a Flutter App Development company. Our Flutter mobile app development team can create cross-platform apps for different industry verticals. Our Flutter developers will help you extend your business’s scope by developing enhanced functionality and a feature-rich app. To provide a rich user experience to your users, hire dedicated Flutter app developers from WebClues Infotech today!

#hire flutter app developers #hire dedicated flutter app developer usa #hire flutter app developer usa #hire dedicated flutter app developer #hire flutter developer #flutter app development company

How much does it cost to make a Flutter app for your business?

Google’s Flutter may be a hot topic lately. This promising technology is often seen fixing new benchmarks and recognition among mobile app developers. Flutter app development is unquestionably an ideal match for everybody trying to find a strong mobile app for his or her next big project. Features like easy usability, fast to code also as compatibility to different platforms validate its success & popularity among global mobile app developers.

Featuring Flutter’s incredible features, during this answer, we are making you conscious of the estimated Flutter mobile app development cost for your new project and the way it is often an economical solution of building a feature-loaded mobile app at a lower cost.

How Flutter App is often an honest fit Your Business?

Flutter comes up with numerous benefits, a number of them being:

  • Flutter platform serves your development purpose for free of charge.
  • This open-source platform is straightforward to find out & work upon.
  • Flutter comes alongside several speedy and customizable widgets.
  • Flutter doesn’t have any compatibility issues with any platform- iOS or Android, unlike other applications.
  • Flutter features a highly expedited development time.
  • Backed by Google, the framework is credible, reliable, accepted by all with a huge community support forum.
  • Flutter may be a hybrid platform and hence helps in providing a wider reach than other applications.
  • The development of the Flutter app is predicated on one codebase that saves time within the process of testing the appliance across different platforms.

How Much Does It Cost to Develop A Flutter App? Factors Determining Cost

Following factors play an excellent role choose the essential cost of the Flutter app development:

  • Hours It takes to UI/UX Design
  • Overall Development Time
  • Backend Server
  • Developer Cost
  • The Complexity of the App
  • Total Hardware Costs
  • App Category
  • Maintenance of the App
  • Location of the event Company

Flutter is way Cost-Effective than Other Platforms

Flutter will go an extended thanks to supporting smaller requirements of a business. the rationale is its cross-platform capabilities within the development that creates it an excellent framework for app development within the future.

Research says that “Flutter applications within the market within the present scenario structure about 0.21% of the apps available with a 0.04% installation rate. Flutter apps are counted within the top apps category with an installation rate of 0.05%.”

It is no wonder that Google’s Flutter is driving the expansion of the appliance development industry to an excellent extent. The framework is often seen helping businesses structure an app with good features and styles at a lower budget and limited requirements.

#flutter app development company in usa #flutter app development services #flutter app development services #best flutter app development company usa #leading flutter app development company #hire flutter developer

Best Flutter App Development Company

Are you looking for the best flutter app development company? Then AppClues Infotech is the leading flutter app development company in USA offering the best service worldwide. We focused on developing hybrid mobile apps on Android & iOS and assures our end-user about exceptional and functionally-rich mobile apps.

For more info:
Website: https://www.appcluesinfotech.com/
Email: info@appcluesinfotech.com
Call: +1-978-309-9910

#top flutter app development company in usa #best flutter app development service #best flutter app development company #hire flutter app developers #flutter app development company #expert flutter app development company

Best Flutter App Development Company in USA & India

AppClues Infotech is one of the best flutter app development company in USA & India. Our diverse and experienced team of developers can help you sketch the smartest and quickest solution for your mobile app development projects with the most superior technology.

For more info:
Website: https://www.appcluesinfotech.com/
Email: info@appcluesinfotech.com
Call: +1-978-309-9910

#top flutter app development company in usa #best flutter app development service #best flutter app development company #hire flutter app developers #flutter app development company in usa & india #custom flutter app development service