intl_messages 2.3.4 copy "intl_messages: ^2.3.4" to clipboard
intl_messages: ^2.3.4 copied to clipboard

Simple and easy internationalization and localization messages framework for Dart (integrated with package 'intl') and translation tools (integrated with OpenAI and ChatGPT).

example/example.dart

import 'package:intl_messages/intl_messages.dart';
import 'package:swiss_knife/swiss_knife.dart';

void main() {
  var uriBase = getUriBase(); // expected `intl_messages/` source dirctory.
  print('uriBase: $uriBase');

  App();

  App('fr');
}

class App {
  final IntlMessagesLoader intlMessagesLoader =
      IntlMessagesLoader('example', 'example/i18n/msgs-');

  IntlMessages get messages => intlMessagesLoader.intlMessages;

  String get msgWelcome => messages.msg('welcome').build();

  String get msgLanguage => messages.msg('language').build();

  String msgTotalEmails(int n, String user) =>
      messages.msg('total_emails').build({'n': n, 'user': user});

  final String? forceLocale;

  App([this.forceLocale]) {
    if (intlMessagesLoader.isLoaded) {
      run();
    } else {
      intlMessagesLoader.onLoad.listen((event) => run());
    }
  }

  void run() {
    if (forceLocale != null) {
      messages.setLocale(forceLocale);
    }

    print('----------------------------- ${messages.currentLocale}');

    print(msgWelcome);

    print('$msgLanguage: ${messages.currentLocale!.language}');

    for (var i = 0; i <= 4; i++) {
      print('$i> ${msgTotalEmails(i, 'Joe')}');
    }
  }
}
5
likes
130
points
2.01k
downloads

Publisher

unverified uploader

Weekly Downloads

Simple and easy internationalization and localization messages framework for Dart (integrated with package 'intl') and translation tools (integrated with OpenAI and ChatGPT).

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

args, async_extension, collection, dart_openai, enum_to_string, intl, path, resource_portable, swiss_knife, yaml

More

Packages that depend on intl_messages