Git Product home page Git Product logo

intl_utils's People

Contributors

bryanortiz avatar davidmartos96 avatar freedomiza avatar goranluledzija avatar jonjomckay avatar lzoran avatar tyxz avatar zazo032 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

intl_utils's Issues

Formatting ICU syntax for easier reading

At the moment I'm fleshing out my error handling for a new app and using Localizely for my l10n. I'm finding it a bad developer experience at the moment to construct the ICU formats that the .arb files are so useful for. For example, I have a whole series of error codes that I pass into a select which allows me to generate a single key-value pair for all of my AuthValueFailures. and makes sure that all my translations are in order.

From my code, I get to just call String errorMessage = l10n.auth_error_authValueError(f.code) and it gives me each and every error message. But the issue I'm having is formating and writing all these error codes so that don't have mistakes that the code generator will skip.

In order to write the ICU format, I either need to rely on the .arb file which is just formated as a single string:

{
  "auth_error_authFailure": "{failure, select, auth_error_cancelledByUser{Cancelled by User.} auth_error_serverError{Server side error.} auth_error_emailAlreadyInUse{Email already in use.} auth_error_accountAlreadyExists{Account already exists.} auth_error_invalidEmailAndPassword{Invalid email and password combo.} auth_error_missingUserDoc{Missing User Document.} auth_error_missingUserSettings{Missing Settings.} auth_error_invalidUserDoc{Invalid User Document.} auth_error_invalidUserSettings{Invalid Settings.} auth_error_insufficientPermission{Insufficient Permissions.} other{Authentication error.}}",
}

or use the Localizely console:

image

Both are very hard to read and check that everything is correct. Worst on the console version as it would record any \n that I used to help separate the lines which resulted in the code generation failing and me having to use replaceAll after uploading new .arb files.

If anyone knows of a way to cleanly format the .arb (Prettier extension?) or knows when the dev team at Localizely will update their console, it would be much appreciated.

@devTeamOfLocalizely; This is such an important feature for my DX that I'm even willing to code the solution myself if you let me access the console code (provided it's in JS/TS)

[BUG] Failed generation when translation string contains \ and $

I have a string in my .arb files that contains a \, something like:

{
  "my_string": "a\\b c\\$d",
}

Note that the \is already escaped, to be treated as a normal character.

When I run intl_utils:generate it fails with the error:

Error in parsing [redacted]/generated/l10n.dart, no messages extracted.
ERROR: Failed to generate localization files.
Invalid argument(s): Parsing errors in [redacted]/generated/l10n.dart

The generated/l10n.dart file is actually generated, but none of the generated/intl/messages_*.dart.

Here is the relevant part of the generated file:

/// `a\b c\$d`
String get my_string {
  return Intl.message(
    'a\b c\\$d',
    name: 'my_string',
    desc: '',
    args: [],
  );
}

There are two separate issues here:

  1. The first \ in the dart string in line 4 is not properly escaped (should be \\) and treated as a control sequence.
  2. The second \ is properly escaped, however the following '$' is not, and therefore treated as a string interpolation symbol. This one actually leads to the above error.

[Proposal] Nested objects in ARB files

With larger translation files, organizing them can get quite difficult.

As the ARB files that are used for generating delegates are in JSON format,
we could perhaps use nested JSON objects?

For example:

{
  "nested": {
     "first": "something",
     "second": "something {param} else"
  }
}

could become String get nestedFirst => _nested["first"] where _nested is a Map<String,String> that is filled with Intl.message and siblings.
In essence, we add an extra parsing case for a Map to the delegate generation.

Default to use main string if locale string is not translated

Let me explain, if I have two languages for my app, main lang is en, the second one is fr, if a string in fr is not translated yet, it would be better to display en string but not ''.
Don't know if this is a issue or a feature need to be accomplished.
Thanks for great plugin!

[Feature] Option to specify additional lint rules in the auto-generated header

Use case:

I have set up my own analysis_options.yaml file with a configuration for the linter rules to use and/or exclude.
If one or more rules in that file conflict with the autogenerated code of the plugin,
I get unnecessary analyzer warnings. (I.e. always_use_package_imports or public_api_docs)

Proposal:

We should instead allow users to add an additional ignore_for_file: <lints the user wants to ignore> above or under the existing ones in the templates.
This would provide users with the ability to still somewhat configure the autogenerated file alongside the linter.

intl 0.17.0 and Flutter 2.0 support

I just updated to flutter 2 and got:

Because client depends on flutter_localizations any from sdk which depends on intl 0.17.0, intl 0.17.0 is required.
So, because client depends on intl 0.16.1, version solving failed.

So I updated that and now I get:

Because intl_utils 1.9.0 depends on intl_translation 0.17.10+1 which depends on intl >=0.15.3 <0.17.0, intl_utils 1.9.0 requires intl >=0.15.3 <0.17.0.
So, because client depends on both intl 0.17.0 and intl_utils 1.9.0, version solving failed.

Tags within translated strings are removed in message_en.dart

I have the following string in intl_en.arb "By continuing, you agree to our\n<l>Terms of Service</l> and <l>Privacy Policy</l>."

After I run flutter pub run intl_utils:generate, the string in message_en.dart becomes MessageLookupByLibrary.simpleMessage("By continuing, you agree to our\n").

I can manually modify the string in simpleMessage by adding the rest of the line to get it to work. However, this wouldn't be a feasible long term work around. It used to generate fine.

Any idea what happened?

Try removing the declaration of '_locale'.dart(unused_element)

while this is just a hint but i think it won't cost much time developing converting this:

/// `en`
  String get _locale {
    return Intl.message(
      'en',
      name: '_locale',
      desc: '',
      args: [],
    );
  }

to

/// `en`
  /// ignore: unused_element
  String get _locale {
    return Intl.message(
      'en',
      name: '_locale',
      desc: '',
      args: [],
    );
  }

instead of manually modifying it every time we generate the files.

Support Intl's dateFormat when present in .arb files

Given this .arb file:

{
    "@@locale": "en",
    "fYanqui": "(yanqui) {date}",
    "@fYanqui": {
        "description": "A message with a date parameter",
        "placeholders": {
            "date": {
                "type": "DateTime",
                "format": "yMd"
            }
        }
    },
    "fArgentina": "(arg) {date}",
    "@fArgentina": {
        "description": "A message with a date parameter",
        "placeholders": {
            "date": {
                "type": "DateTime",
                "format": "yMMMEd"
            }
        }
    },
}

the generated code is:

/// `(yanqui) {date}`
  String fYanqui(Object date) {
    return Intl.message(
      '(yanqui) $date',
      name: 'fYanqui',
      desc: 'A message with a date parameter',
      args: [date],
    );
  }

  /// `(arg) {date}`
  String fArgentina(Object date) {
    return Intl.message(
      '(arg) $date',
      name: 'fArgentina',
      desc: 'A message with a date parameter',
      args: [date],
    );
  }

Instead of this one that generates flutter_gen:

@override
String fYanqui(DateTime date) {
  final intl.DateFormat dateDateFormat = intl.DateFormat.yMd(localeName);
  final String dateString = dateDateFormat.format(date);

  return '(yanqui) ${dateString}';
}

@override
String fArgentina(DateTime date) {
  final intl.DateFormat dateDateFormat = intl.DateFormat.yMMMEd(localeName);
  final String dateString = dateDateFormat.format(date);

  return '(arg) ${dateString}';
}

What 'type's can I use for placeholders?

Perhaps I've missed something but I've been trolling the inter webs for hours trying to figure this out.

AS far as I can tell I can use the 'String' type for a placeholder like this in a *.arb file:

"workedHoursGraphCriteriaLastNDays": "Last {days} days",
  "@workedHoursGraphCriteriaLastNDays": {
    "placeholders": {
      "days": {
        "type": "String"
      }
    }
  }

That works. Now I want to inject a number but I can't seem to find any docs on what type to specify or in fact, any other types. I tried int but the generator fails saying it isn't supported and to check the NumberFormat class for details. I also tried 'number', 'Number', 'Int', 'int', 'double', 'Decimal' and others. I'd either get told to look at 'NumberFormat' or a compilation failure.

Unfortunately NumberFormat isn't that helpful. It knows nothing of '*.arb' files and I've not been able to find anything on the web that talks about what the options are.

Is there a list of value types somewhere?

NULL-safety

This package should provide a nullsafe version. Since both, flutter_localizations and intl now provide a nullsafe preview version, this package should do the same, so we can generate nullsafe translations.

Allow folder starting with a dot (e.g., lib/.generated)

Hello 🙂

I would like to propose this enhancement to enable the generation of folders that start with a dot ".".
I think that modifying the current regex string in the isValidPath(...) method should be enough.

The rationale is that when you run flutter format there is no way to tell it to exclude some folders, such as the generated ones, and the only workaround at the moment is to provide the generated folders with a starting dot, so that Flutter would skip them.

Problem with HTML inside l10n

Hello!

I have a strange use case in my company. One of the sentences in the arb files have text with HTML code and variables. This was working fine before commit b3297b9

In that commit the parser nonIcuMessageText is removed from the parse function (by removing simpleText). Without this parser the code ends up with a null exception.

Problem:
imagen

Debug:
imagen
imagen

(VariableSubstitution(null) is the problem here since l10n have no parameters in that function)

It can be fixed changing the icu_parser.dart:

Parser get contents => pluralOrGenderOrSelect | parameter | messageText | nonIcuMessageText; (sdurban@3389dfb)

But this breaks a lot of test cases... Not sure what to do here... Any Advice?

After adding intl_utils to project have the problem

pubspec.yaml:

environment:
  sdk: ">=2.7.0 <3.0.0"

dependencies:
  intl_utils: ^1.9.0

flutter_intl:
  enabled: true
  localizely:
    project_id: XXX
flutter --no-color pub global run intl_utils:generate

Precompiling executable...
Failed to precompile intl_utils:generate:
../../flutter/.pub-cache/hosted/pub.dartlang.org/path-1.8.0/lib/path.dart:1:1: Error: The specified language version is too high. The highest supported language version is 2.10.
// Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file
^
../../flutter/.pub-cache/hosted/pub.dartlang.org/path-1.8.0/lib/src/context.dart:1:1: Error: The specified language version is too high. The highest supported language version is 2.10.
// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file
^
../../flutter/.pub-cache/hosted/pub.dartlang.org/path-1.8.0/lib/src/style.dart:1:1: Error: The specified language version is too high. The highest supported language version is 2.10.
// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file
^
../../flutter/.pub-cache/hosted/pub.dartlang.org/path-1.8.0/lib/src/path_exception.dart:1:1: Error: The specified language version is too high. The highest supported language version is 2.10.
// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file
^
../../flutter/.pub-cache/hosted/pub.dartlang.org/path-1.8.0/lib/src/path_map.dart:1:1: Error: The specified language version is too high. The highest supported language version is 2.10.
// Copyright (c) 2018, the Dart project authors.  Please see the AUTHORS file
^
../../flutter/.pub-cache/hosted/pub.dartlang.org/path-1.8.0/lib/src/path_set.dart:1:1: Error: The specified language version is too high. The highest supported language version is 2.10.
// Copyright (c) 2018, the Dart project authors.  Please see the AUTHORS file
^
../../flutter/.pub-cache/hosted/pub.dartlang.org/charcode-1.2.0/lib/ascii.dart:1:1: Error: The specified language version is too high. The highest supported language version is 2.10.
// Copyright (c) 2014, the Dart project authors.  Please see the AUTHORS file
^
../../flutter/.pub-cache/hosted/pub.dartlang.org/source_span-1.8.1/lib/source_span.dart:1:1: Error: The specified language version is too high. The highest supported language version is 2.10.
// Copyright (c) 2014, the Dart project authors.  Please see the AUTHORS file
^
../../flutter/.pub-cache/hosted/pub.dartlang.org/collection-1.15.0/lib/collection.dart:1:1: Error: The specified language version is too high. The highest supported language version is 2.10.
// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file
^
../../flutter/.pub-cache/hosted/pub.dartlang.org/path-1.8.0/lib/src/characters.dart:1:1: Error: The specified language version is too high. The highest supported language version is 2.10.
// Copyright (c) 2014, the Dart project authors.  Please see the AUTHORS file
^
pub finished with exit code 1
Process finished with exit code 1
flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 1.22.6, on Mac OS X 10.15.7 19H114 darwin-x64, locale en-US)
 
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 12.3)
[✓] Android Studio (version 4.0)
[✓] IntelliJ IDEA Ultimate Edition (version 2019.3.2)
[✓] VS Code (version 1.53.2)
[✓] Connected device (1 available)

• No issues found!

Running flutter pub cache repair doesn't seem to work with vscode version of intl_utils?

Steps to reproduce

  1. Install Flutter intl in VSCode (which installs intl_utils in $HOME/.pub-cache/hosted/pub.dartlang.org/intl_utils-2.2.0)
  2. run flutter pub cache repair

Logs

Reinstalled 316 packages.
Reactivating intl_utils 2.2.0...
Precompiling executables...
Failed to precompile intl_utils:generate:
Error: Couldn't resolve the package 'intl_utils' in 'package:intl_utils/intl_utils.dart'.
Error: Couldn't resolve the package 'intl_utils' in 'package:intl_utils/src/generator/generator_exception.dart'.
Error: Couldn't resolve the package 'intl_utils' in 'package:intl_utils/src/utils/utils.dart'.
intl_utils-2.2.0/bin/generate.dart:3:8: Error: Not found: 'package:intl_utils/intl_utils.dart'
import 'package:intl_utils/intl_utils.dart';
       ^
intl_utils-2.2.0/bin/generate.dart:4:8: Error: Not found: 'package:intl_utils/src/generator/generator_exception.dart'
import 'package:intl_utils/src/generator/generator_exception.dart';
       ^
intl_utils-2.2.0/bin/generate.dart:5:8: Error: Not found: 'package:intl_utils/src/utils/utils.dart'
import 'package:intl_utils/src/utils/utils.dart';
       ^
intl_utils-2.2.0/bin/generate.dart:9:21: Error: Method not found: 'Generator'.
    var generator = Generator();
                    ^^^^^^^^^
intl_utils-2.2.0/bin/generate.dart:11:8: Error: 'GeneratorException' isn't a type.
  } on GeneratorException catch (e) {
       ^^^^^^^^^^^^^^^^^^
intl_utils-2.2.0/bin/generate.dart:12:5: Error: Method not found: 'exitWithError'.
    exitWithError(e.message);
    ^^^^^^^^^^^^^
intl_utils-2.2.0/bin/generate.dart:14:5: Error: Method not found: 'exitWithError'.
    exitWithError('Failed to generate localization files.\n$e');
    ^^^^^^^^^^^^^
Failed to precompile intl_utils:localizely_download:
Error: Couldn't resolve the package 'intl_utils' in 'package:intl_utils/src/config/config_exception.dart'.
Error: Couldn't resolve the package 'intl_utils' in 'package:intl_utils/src/config/credentials_config.dart'.
Error: Couldn't resolve the package 'intl_utils' in 'package:intl_utils/src/config/pubspec_config.dart'.
Error: Couldn't resolve the package 'intl_utils' in 'package:intl_utils/src/constants/constants.dart'.
Error: Couldn't resolve the package 'intl_utils' in 'package:intl_utils/src/localizely/api/api_exception.dart'.
Error: Couldn't resolve the package 'intl_utils' in 'package:intl_utils/src/localizely/service/service.dart'.
Error: Couldn't resolve the package 'intl_utils' in 'package:intl_utils/src/localizely/service/service_exception.dart'.
Error: Couldn't resolve the package 'intl_utils' in 'package:intl_utils/src/utils/file_utils.dart'.
Error: Couldn't resolve the package 'intl_utils' in 'package:intl_utils/src/utils/utils.dart'.
intl_utils-2.2.0/bin/localizely_download.dart:6:8: Error: Not found: 'package:intl_utils/src/config/config_exception.dart'
import 'package:intl_utils/src/config/config_exception.dart';
       ^
Failed to precompile intl_utils:localizely_upload_main:
Error: Couldn't resolve the package 'intl_utils' in 'package:intl_utils/src/config/config_exception.dart'.
Error: Couldn't resolve the package 'intl_utils' in 'package:intl_utils/src/config/credentials_config.dart'.
Error: Couldn't resolve the package 'intl_utils' in 'package:intl_utils/src/config/pubspec_config.dart'.
Error: Couldn't resolve the package 'intl_utils' in 'package:intl_utils/src/constants/constants.dart'.
Error: Couldn't resolve the package 'intl_utils' in 'package:intl_utils/src/localizely/api/api_exception.dart'.
Error: Couldn't resolve the package 'intl_utils' in 'package:intl_utils/src/localizely/service/service.dart'.
Error: Couldn't resolve the package 'intl_utils' in 'package:intl_utils/src/localizely/service/service_exception.dart'.
Error: Couldn't resolve the package 'intl_utils' in 'package:intl_utils/src/utils/file_utils.dart'.
Error: Couldn't resolve the package 'intl_utils' in 'package:intl_utils/src/utils/utils.dart'.
intl_utils-2.2.0/bin/localizely_upload_main.dart:6:8: Error: Not found: 'package:intl_utils/src/config/config_exception.dart'
import 'package:intl_utils/src/config/config_exception.dart';
       ^
Failed to reactivate intl_utils 2.2.0: Failed to precompile intl_utils:generate:
Error: Couldn't resolve the package 'intl_utils' in 'package:intl_utils/intl_utils.dart'.
Error: Couldn't resolve the package 'intl_utils' in 'package:intl_utils/src/generator/generator_exception.dart'.
Error: Couldn't resolve the package 'intl_utils' in 'package:intl_utils/src/utils/utils.dart'.
intl_utils-2.2.0/bin/generate.dart:3:8: Error: Not found: 'package:intl_utils/intl_utils.dart'
import 'package:intl_utils/intl_utils.dart';
       ^
intl_utils-2.2.0/bin/generate.dart:4:8: Error: Not found: 'package:intl_utils/src/generator/generator_exception.dart'
import 'package:intl_utils/src/generator/generator_exception.dart';
       ^
intl_utils-2.2.0/bin/generate.dart:5:8: Error: Not found: 'package:intl_utils/src/utils/utils.dart'
import 'package:intl_utils/src/utils/utils.dart';
       ^
intl_utils-2.2.0/bin/generate.dart:9:21: Error: Method not found: 'Generator'.
    var generator = Generator();
                    ^^^^^^^^^
intl_utils-2.2.0/bin/generate.dart:11:8: Error: 'GeneratorException' isn't a type.
  } on GeneratorException catch (e) {
       ^^^^^^^^^^^^^^^^^^
intl_utils-2.2.0/bin/generate.dart:12:5: Error: Method not found: 'exitWithError'.
    exitWithError(e.message);
    ^^^^^^^^^^^^^
intl_utils-2.2.0/bin/generate.dart:14:5: Error: Method not found: 'exitWithError'.
    exitWithError('Failed to generate localization files.\n$e');
    ^^^^^^^^^^^^^
Reactivating devtools 2.3.3...
Precompiling executables...
Precompiled devtools:devtools.
Installed executable devtools.
Reactivated 1 package.
Failed to reactivate 1 package:
- intl_utils
pub finished with exit code 69
➜  pub.dartlang.org 

Runing pub get in intl_utils packages

[intl_utils-2.2.0] dart pub get
Resolving dependencies...
+ _fe_analyzer_shared 22.0.0
+ analyzer 1.7.0 (1.7.1 available)
+ archive 3.1.2
+ args 2.1.1
+ async 2.7.0
+ boolean_selector 2.1.0
+ build 2.0.2
+ build_config 0.4.7 (1.0.0 available)
+ build_daemon 2.1.10 (3.0.0 available)
+ build_resolvers 2.0.3
+ build_runner 1.12.2 (2.0.5 available)
+ build_runner_core 6.1.12 (7.0.0 available)
+ built_collection 5.1.0
+ built_value 8.1.0
+ charcode 1.3.1
+ checked_yaml 2.0.1
+ cli_util 0.3.0
+ clock 1.1.0
+ code_builder 3.7.0 (4.0.0 available)
+ collection 1.15.0
+ convert 3.0.0
+ coverage 1.0.3
+ crypto 3.0.1
+ dart_style 2.0.1
+ file 6.1.2
+ fixnum 1.0.0
+ frontend_server_client 2.1.0
+ glob 2.0.1
+ graphs 1.0.0 (2.0.0 available)
+ http 0.13.3
+ http_multi_server 3.0.1
+ http_parser 4.0.0
+ intl 0.17.0
+ io 1.0.0
+ js 0.6.3
+ json_annotation 4.0.1
+ logging 1.0.1
+ matcher 0.12.10
+ meta 1.4.0
+ mime 1.0.0
+ mockito 5.0.7 (5.0.10 available)
+ node_preamble 2.0.1
+ package_config 2.0.0
+ path 1.8.0
+ pedantic 1.11.1
+ petitparser 4.1.0 (4.2.0 available)
+ pool 1.5.0
+ pub_semver 2.0.0
+ pubspec_parse 1.0.0
+ shelf 1.1.4
+ shelf_packages_handler 3.0.0
+ shelf_static 1.0.0
+ shelf_web_socket 1.0.1
+ source_gen 1.0.2
+ source_map_stack_trace 2.1.0
+ source_maps 0.10.10
+ source_span 1.8.1
+ stack_trace 1.10.0
+ stream_channel 2.1.0
+ stream_transform 2.0.0
+ string_scanner 1.1.0
+ term_glyph 1.2.0
+ test 1.17.8
+ test_api 0.4.1
+ test_core 0.3.28
+ timing 1.0.0
+ typed_data 1.3.0
+ vm_service 7.1.0
+ watcher 1.0.0
+ web_socket_channel 2.1.0
+ webkit_inspection_protocol 1.0.0
+ yaml 3.1.0
Cannot open file, path = $HOME/.pub-cache/global_packages/intl_utils/pubspec.lock' (OS Error: No such file or directory, errno = 2)
exit code 66

[Question] How can I generate arb file from dart file ?

Before migration to your library, I was using intl_translation and there it was possible to generate arb file based on the dart file
localizations/app_localizations.dart in my case

with structure like

class AppLocalizations {
  AppLocalizations(this.localeName);

  static Future<AppLocalizations> load(Locale locale) {
    final String name =
        locale.countryCode.isEmpty ? locale.languageCode : locale.toString();
    final String localeName = Intl.canonicalizedLocale(name);
    return initializeMessages(localeName).then((_) {
      return AppLocalizations(localeName);
    });
  }

  static AppLocalizations of(BuildContext context) {
    return Localizations.of<AppLocalizations>(context, AppLocalizations);
  }

  final String localeName;

  // login and registration
  String get prompt_email => Intl.message('Email', name: 'prompt_email');

  String get prompt_password =>
      Intl.message('Fjalёkalimi', name: 'prompt_password');

I could run before

flutter pub run intl_translation:extract_to_arb --output-dir=lib/l10n lib/localization/app_localizations.dart

and this generated arb files, that could then modify/translate, then generate the dart files for every locale (which is working fine with your library this part too by flutter pub run intl_utils:generate

incompatibility with last version of freezed

Because intl_utils >=1.9.0 depends on intl_translation 0.17.10+1 which depends on analyzer ^0.39.12, intl_utils >=1.9.0 requires analyzer ^0.39.12.

And because freezed 0.12.3 depends on analyzer >=0.40.4 <1.0.0 and no versions of freezed match >0.12.3 <0.13.0, intl_utils >=1.9.0 is incompatible with freezed ^0.12.3.

Feature request: description as comments on getters

I'd like to have the description of each arb string to be converted to a comment on the corresponding getter along with current implementation.

instead of this:

image

I'd like this:

image

This way flutter/dart extension can provide intellisense like this.

image

Difference between `current` and `of()`

Hi

I can access the class by using the static variable current or by the static function of(context)

An example of my generated class is:

class I18n {
  I18n();
  
  static I18n current;
  
  static I18n of(BuildContext context) {
    return Localizations.of<I18n>(context, I18n);
  }

What's the difference between each way?
What will be the consequence of using current everywhere?

(Question) What does the defaultClassName "S" mean?

Hello. I am grateful for this package.

I have a brief question. What does the defaultClassName "S" mean? Strings maybe?

(I think it would be convenient if the reasons were commented in the README or source code.)

Custom path for generated files

I want to be able to place all generated code in a custom directory instead of the default generated path, via an option in pubspec.yaml

flutter_intl:
     custom_path: "my_custom_directory"

So this would place all the code in lib/my_custom_directory instead of lib/generated

I needed this pretty quick, so I forked this and added support for a custom path option

I can make a PR, clean up some things, and check for anything I missed if You guys want to add this option.

Provide a way to dinamically load a translation

I would like to be able to be able to load a translation dinamically, but there's no option to do it right now:

Use case

Defined translations:

  • key_1
  • key_2

If the text to load is defined via API, there's no way to dinamically load key_1 in the app.

It would be great if default S class had (or at least via opt-in) something like:

S.of(context).text('key_1');
S.of(context).text(variable);

The current workaround would be to define a switch that depending on the value from API, it would return the S message, but that's not very feasible when there a lot of possible values.

Can i Customize the directory structure for storing ARB files?

我可以 自定义存放ARB文件目录结构 吗?
Can i Customize the directory structure for storing ARB files?

1 自定义存放ARB文件目录结构;
2 自定义 ./lib/generated/l10n.dart 文件 和 ./lib/generated/intl 目录 的目录结构;

1 Customize the directory structure for storing ARB files;
2 Customize the ./lib/generated/l10n.dart file and the "directory/lib/generated/intl" directory structure;

incompatiblity with flutter_driver (flutter 2)?

in a fresh app:

flutter create myapp

with this pubspec

name: myapp
description: A new Flutter project.
publish_to: 'none'
version: 1.0.0+1

environment:
  sdk: ">=2.7.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter
  flutter_localizations:
    sdk: flutter

dev_dependencies:
  flutter_driver:
    sdk: flutter
  flutter_test:
    sdk: flutter
  intl_utils: any

flutter:
  uses-material-design: true

I get this error:


--

[myapp] flutter pub get
Running "flutter pub get" in myapp...                           
Because every version of flutter_driver from sdk depends on webdriver 2.1.2 which depends on archive >=1.0.0 <3.0.0, every version of flutter_driver from sdk requires archive >=1.0.0 <3.0.0.
And because intl_utils >=2.0.0 depends on archive ^3.0.0, flutter_driver from sdk is incompatible with intl_utils >=2.0.0.


And because intl_utils ^1.9.0 depends on intl_translation 0.17.10+1 and intl_utils >=1.6.3 <1.9.0 depends on intl_translation 0.17.10, if flutter_driver any from sdk and intl_utils >=1.6.3 then intl_translation 0.17.10 or 0.17.10+1.
Because intl_utils <1.2.1 depends on intl_translation 0.17.8 and intl_utils >=1.2.1 <1.6.3 depends on intl_translation 0.17.9, intl_utils <1.6.3 requires intl_translation 0.17.8 or 0.17.9.



Thus, if flutter_driver any from sdk and intl_utils any then intl_translation 0.17.8 or 0.17.9 or 0.17.10 or 0.17.10+1.
And because intl_translation >=0.17.7 depends on intl >=0.15.3 <0.17.0, if flutter_driver any from sdk and intl_utils any then intl >=0.15.3 <0.17.0.
And because myapp depends on flutter_localizations any from sdk which depends on intl 0.17.0, flutter_driver from sdk is incompatible with intl_utils.


So, because myapp depends on both flutter_driver any from sdk and intl_utils any, version solving failed.
pub get failed (1; So, because myapp depends on both flutter_driver any from sdk and intl_utils any, version solving failed.)
exit code 1

flutter doctor

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.0.4, on Linux, locale en_US.utf8)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[✓] Chrome - develop for the web
[✓] Android Studio
[✓] VS Code (version 1.55.1)
[✓] Connected device (1 available)

• No issues found!

Localizations.override override the whole app

Perhaps this is a problem with flutter itself and not this awesome package but maybe you can help me narrow the problem so I can open the issue in the Flutter project instead (There is already a similar problem in Flutter issues flutter/flutter#33300)

When using AboutListTile() > Opening Dialog > See Licenses > Tap on any License the Localization becomes English for the whole app, Reading the code they use Localizations.override(locale: const Locale('en', 'US'), ...) so the license page load only in English, the problem is that Localizations.override should only override that page, but it changes the whole app language to English


void main() {
  runApp(const App());
}

// Run the app in other language (Spanish) and after opening licenses and visualizes one

class Appextends StatelessWidget {
  const GameShop({Key key}) : super(key: key);

  @override
  Widget build(BuildContext contexth) {
    return MaterialApp(
      localizationsDelegates: [
        S.delegate,
        GlobalMaterialLocalizations.delegate,
        GlobalWidgetsLocalizations.delegate,
        GlobalCupertinoLocalizations.delegate,
      ],
      supportedLocales: S.delegate.supportedLocales,
      home: Builder(
          builder: (context) => Scaffold(
              body: AboutListTile(
                  applicationName: S.of(context).example_text
              ),
          )
      ),
    );
  }
}
[√] Flutter (Channel stable, 1.22.5, on Microsoft Windows [Versión 10.0.18363.1316], locale es-MX)
    • Flutter version 1.22.5 at E:\Programs\flutter
    • Framework revision 7891006299 (5 weeks ago), 2020-12-10 11:54:40 -0800
    • Engine revision ae90085a84
    • Dart version 2.10.4

 
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    • Android SDK at C:\Users\dartz\AppData\Local\Android\Sdk
    • Platform android-30, build-tools 30.0.2
    • ANDROID_HOME = C:\Users\dartz\AppData\Local\Android\Sdk
    • Java binary at: E:\Programs\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
    • All Android licenses accepted.

[!] Android Studio (version 4.1.0)
    • Android Studio at E:\Programs\Android\Android Studio
    X Flutter plugin not installed; this adds Flutter specific functionality.
    X Dart plugin not installed; this adds Dart specific functionality.
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)

pubspec configuration option to exclude / include tags

It would be great if we could specify tags that will not converted to Dart code when downloading updated translations.

flutter_intl:
  enabled: false
  exclude_tags: 
    - EmailTemplates 
  // -- or --
  include_tags:
    - SignUp
    - Settings
    - Home Page
    - Gallery

I have a handful of keys that belong to the project but are not (yet) needed in the final app like email templates. This way they are not shipped unnecessarily.

After moving to this lib from old one, wrongly parsed keys when containing encoded json strings

Simple .arb file that previously was parsed correctly, intl_en.arb

{
  "weight_options": "[\"-\",\"< 39 kg\",\"40 kg\",\"41 kg\",\"42 kg\",\"43 kg\",\"44 kg\",\"45 kg\",\"46 kg\",\"47 kg\",\"48 kg\",\"49 kg\",\"50 kg\",\"51 kg\",\"52 kg\",\"53 kg\",\"54 kg\",\"55 kg\",\"56 kg\",\"57 kg\",\"58 kg\",\"59 kg\",\"60 kg\",\"61 kg\",\"62 kg\",\"63 kg\",\"64 kg\",\"65 kg\",\"66 kg\",\"67 kg\",\"68 kg\",\"69 kg\",\"70 kg\",\"71 kg\",\"72 kg\",\"73 kg\",\"74 kg\",\"75 kg\",\"76 kg\",\"77 kg\",\"78 kg\",\"79 kg\",\"80 kg\",\"81 kg\",\"82 kg\",\"83 kg\",\"84 kg\",\"85 kg\",\"86 kg\",\"87 kg\",\"88 kg\",\"89 kg\",\"90 kg\",\"91 kg\",\"92 kg\",\"93 kg\",\"94 kg\",\"95 kg\",\"96 kg\",\"97 kg\",\"98 kg\",\"99 kg\",\"100 kg\",\"101 kg\",\"102 kg\",\"103 kg\",\"104 kg\",\"105 kg\",\"106 kg\",\"107 kg\",\"108 kg\",\"109 kg\",\"110 kg\",\"111 kg\",\"112 kg\",\"113 kg\",\"114 kg\",\"115 kg\",\"116 kg\",\"117 kg\",\"118 kg\",\"119 kg\",\"120 kg\",\"121 kg\",\"122 kg\",\"123 kg\",\"124 kg\",\"125 kg\",\"126 kg\",\"127 kg\",\"128 kg\",\"129 kg\",\"130 kg\",\"131 kg\",\"132 kg\",\"133 kg\",\"134 kg\",\"135 kg\",\"136 kg\",\"137 kg\",\"138 kg\",\"139 kg\",\"140 kg\",\"141 kg\",\"142 kg\",\"143 kg\",\"144 kg\",\"145 kg\",\"146 kg\",\"147 kg\",\"148 kg\",\"149 kg\",\"> 150 kg\"]",
}

INVALID Generated result now in lib/l10n/intl/messages_en.dartmessages_en.dart is :

"weight_options": MessageLookupByLibrary.simpleMessage("[\"-\",\""),

This bug went to production because of no error and we missed it in changed translations.
Normally we expect error if your updated generator cannot handle encoded json in string instead of sending wrong data.

In old version plugin intl (before upgrade to new flutter) this was handled correctly into expected result

"weight_options": MessageLookupByLibrary.simpleMessage(
            "[\"-\",\"< 39 kg\",\"40 kg\",\"41 kg\",\"42 kg\",\"43 kg\",\"44 kg\",\"45 kg\",\"46 kg\",\"47 kg\",\"48 kg\",\"49 kg\",\"50 kg\",\"51 kg\",\"52 kg\",\"53 kg\",\"54 kg\",\"55 kg\",\"56 kg\",\"57 kg\",\"58 kg\",\"59 kg\",\"60 kg\",\"61 kg\",\"62 kg\",\"63 kg\",\"64 kg\",\"65 kg\",\"66 kg\",\"67 kg\",\"68 kg\",\"69 kg\",\"70 kg\",\"71 kg\",\"72 kg\",\"73 kg\",\"74 kg\",\"75 kg\",\"76 kg\",\"77 kg\",\"78 kg\",\"79 kg\",\"80 kg\",\"81 kg\",\"82 kg\",\"83 kg\",\"84 kg\",\"85 kg\",\"86 kg\",\"87 kg\",\"88 kg\",\"89 kg\",\"90 kg\",\"91 kg\",\"92 kg\",\"93 kg\",\"94 kg\",\"95 kg\",\"96 kg\",\"97 kg\",\"98 kg\",\"99 kg\",\"100 kg\",\"101 kg\",\"102 kg\",\"103 kg\",\"104 kg\",\"105 kg\",\"106 kg\",\"107 kg\",\"108 kg\",\"109 kg\",\"110 kg\",\"111 kg\",\"112 kg\",\"113 kg\",\"114 kg\",\"115 kg\",\"116 kg\",\"117 kg\",\"118 kg\",\"119 kg\",\"120 kg\",\"121 kg\",\"122 kg\",\"123 kg\",\"124 kg\",\"125 kg\",\"126 kg\",\"127 kg\",\"128 kg\",\"129 kg\",\"130 kg\",\"131 kg\",\"132 kg\",\"133 kg\",\"134 kg\",\"135 kg\",\"136 kg\",\"137 kg\",\"138 kg\",\"139 kg\",\"140 kg\",\"141 kg\",\"142 kg\",\"143 kg\",\"144 kg\",\"145 kg\",\"146 kg\",\"147 kg\",\"148 kg\",\"149 kg\",\"> 150 kg\"]"),

Ignore or fix some lint errors and warnings

Hi. It would be great if you could fix these things:

  1. invalid_assignment error in messages_*.dart files:
class MessageLookup extends MessageLookupByLibrary {
  String get localeName => '...';

  final messages = _notInlinedMessages(_notInlinedMessages);
  static _notInlinedMessages(_) => <String, Function> {
    "..." : MessageLookupByLibrary.simpleMessage("...")
  };
}

Problematic line of code final messages = _notInlinedMessages(_notInlinedMessages);:

A value of type 'dynamic' can't be assigned to a variable of type 'Map<String, dynamic>'.
Try changing the type of the variable, or casting the right-hand type to 'Map<String, dynamic>'.

And also ignore always_declare_return_types or add return type to _notInlinedMessages.

  1. messages_all.dart file: ignore prefer_final_locals, prefer_final_in_for_each, avoid_redundant_argument_values.
  2. l10n.dart file: ignore join_return_with_assignment, prefer_final_locals, prefer_final_in_for_each, avoid_redundant_argument_values.

Dependencies are broken on flutter dev channel

And because every version of flutter_driver from sdk depends on archive 3.0.0, intl_utils ^1.9.0 is incompatible with flutter_driver from sdk.
So, because my_app depends on both flutter_driver any from sdk and intl_utils ^1.9.0, version solving failed.
pub get failed (1; So, because my_app depends on both flutter_driver any from sdk and intl_utils ^1.9.0, version solving failed.)

It doesn't work with Flutter Module?

I created a "Flutter Module" in Android Studio, added flutter_intl: enabled: true to the pubspecs.yaml, then run pub get, and then click debug button. It fails with this logs:
No application found for TargetPlatform.ios.
Is your project missing an ios/Runner/Info.plist?
Consider running "flutter create ." to create one.

After I deleted flutter_intl: enabled: true from the pubspecs.yaml, it works well. So I'm wondering, is it true that this doesn't support "Flutter Module" or I'm using it the wrong way? If I'm using it the wrong way, How can I use it in an Flutter Module?

My environments:
flutter 2.2.2 stable channel dart:2.13.3

Generated Code not working

I've got a problem with the generated code for the internationalization.

Localizations.of<I18n>(context, I18n);

This line return an nullable object, but the generated class returns an not nullable object.

static I18n of(BuildContext context) { return Localizations.of<I18n>(context, I18n); }

This is code from the generated file "l10n.dart"

The second error I got in this file is the static current variable that is not initialized yet.

static I18n current;

And the last error is in the "messages_all.dart"

you return null in a not nullable context.

MessageLookupByLibrary _findExact(String localeName) { switch (localeName) { case 'de': return messages_de.messages; case 'en': return messages_en.messages; default: return null; } }

MessageLookupByLibrary _findGeneratedMessagesFor(String locale) { var actualLocale = Intl.verifiedLocale(locale, _messagesExistFor, onFailure: (_) => null); if (actualLocale == null) return null; return _findExact(actualLocale); }

This seems to be not null-sound-safety yet. It would be nice if this would be made possible because I love your plugin.
(I use the android studio plugin by the way)

Here are my infos:

  • Android Studio 2020.3.1 Patch 2
  • Flutter 2.5.0
  • Dart 2.14.0

Feature request : Support delegates from multiple dart modules

Hi,

when splitting our project in dart modules for keep the code and decouple we had struggles to decouple the translation files. We would like to have access to the messages from all dart modules.

We find a way to do it by using this importing this package
multiple_localization

and modifying the GENERATED CODE by just changing this method:
@override Future<S> load(Locale locale) => S.load(locale);

BY THIS

@override Future<S> load(Locale locale) => MultipleLocalizations.load(initializeMessages, locale, (l) => S(), setDefaultLocale: true);

and adding all delegates we need
image

Do you think is something that can be easy implement in the code generator to have a flag to enable the use of this module?
This will be a huge thing for us.

Best regards,
LMM

intl_utils using older version

Hello,

We are trying to use intl_utils in our CI pipeline using the following command:

flutter packages pub global activate intl_utils && flutter pub global run intl_utils:generate

When we run the above command we get version 1.9.0 of intl_utils. Shouldn't we get 2.1.0?

Generate files without null safety when using Dart 2.11 or lower

Hello,
since many big apps are going to take a while to migrate all their dependencies to null safety versions, it would be nice to generate the localization files while in compatibility mode.
At the moment, running the following command with Flutter 2.0, intl_utils 2.0.0 and Dart SDK constraint >=2.11, it throws an error:

flutter pub run --no-sound-null-safety intl_utils:generate

Error in parsing /****/lib/generated/l10n.dart, no messages extracted.
ERROR: Failed to generate localization files.
Invalid argument(s): Parsing errors in /****/lib/generated/l10n.dart
pub finished with exit code 2

The parsing error seems to be that the l10n.dart file generates a nullable variable:

static AppLocalizations? current;

I believe this is fixable. There are other generator packages that can be run in this "compatibility" mode. moor_generator or built_value are an example. I think the analyzer package has the capability to check the environment in which it is being executed.

How to unit test with localizations

When I use the generated localizations class, how can I unit test my widgets?

E.G:
Widget:

class HelloWorldWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Center(Text(S.of(context).helloWorld));
  }
}

Unit Test:

void main() {
  testWidgets('HelloWorldWidget has hello world text',
      (WidgetTester tester) async {
    await tester.pumpWidget(HelloWorldWidget());

    final linkFinder = find.text('Hello World'); // this should be localized
    expect(linkFinder, findsOneWidget);
  });
}

Currently all I get is a null-ref exception.

[intl_utils: 2.1.0] _current != null': No instance of S was loaded.

Hello team,

We've just found one very funky area within localisation while using tests.

Consider using class test_class.dart

class TestClass {
  String name = S.current.title;
}

And test class test_class_test.dart

main() {
  final strings = S();

  test("Test", () {
    TestClass testClass = TestClass();
    expect(testClass.name, strings.title);
  });
}

Given title is localised, when we run the test, we will see this error

Failed assertion: line 21 pos 12: '_current != null': No instance of S was loaded. Try to initialise the S delegate before accessing S.current.

Checking upon it, that's correct

static S get current {
    assert(_current != null, 'No instance of S was loaded. Try to initialise the S delegate before accessing S.current.');
    return _current!;
  }

S was never initialised, because we are loading model via test.
My question is, why there is an assertion? If S is null, shouldn't S be initialised automatically?

static S get current {
    if(_current == null) _current = S();
    return _current!;
  }

This way particular error is avoided. Was wondering, is it a bug or this is expected behaviour? If it's expected behaviour, what's the recommended way to handle it?

Before null safety, one can simply check if current is null and if it it - assign S(). But now, since current is defined as non-nullable we cannot check for its nullability.

TIA

Value not in range: 9, exiting with code 2

I cannot update dart file from arb to dart.

flutter pub run intl_utils:generate -v

[ +138 ms] executing: [/Users/marslab/flutter/] git -c log.showSignature=false log -n 1 --pretty=format:%H
[  +67 ms] Exit code 0 from: git -c log.showSignature=false log -n 1 --pretty=format:%H
[   +3 ms] 9b2d32b605630f28625709ebd9d78ab3016b2bf6
[        ] executing: [/Users/marslab/flutter/] git tag --points-at HEAD
[ +142 ms] Exit code 0 from: git tag --points-at HEAD
[        ] 1.22.6
[  +15 ms] executing: [/Users/marslab/flutter/] git rev-parse --abbrev-ref --symbolic @{u}
[   +8 ms] Exit code 128 from: git rev-parse --abbrev-ref --symbolic @{u}
[        ] fatal: HEAD does not point to a branch
[  +24 ms] executing: [/Users/marslab/flutter/] git rev-parse --abbrev-ref HEAD
[  +11 ms] Exit code 0 from: git rev-parse --abbrev-ref HEAD
[        ] HEAD
[  +56 ms] Artifact Instance of 'AndroidMavenArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
[  +10 ms] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[   +1 ms] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[   +1 ms] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[   +5 ms] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[   +3 ms] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[   +1 ms] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[  +17 ms] Artifact Instance of 'MaterialFonts' is not required, skipping update.
[        ] Artifact Instance of 'GradleWrapper' is not required, skipping update.
[        ] Artifact Instance of 'AndroidMavenArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
[   +1 ms] Artifact Instance of 'FlutterSdk' is not required, skipping update.
[        ] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[   +1 ms] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[   +8 ms] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[   +1 ms] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FontSubsetArtifacts' is not required, skipping update.
[  +22 ms] Using /Users/marslab/flutter/.pub-cache for the pub cache.
[   +2 ms] executing: /Users/marslab/flutter/bin/cache/dart-sdk/bin/pub run intl_utils:generate -v
ERROR: Failed to generate localization files.
RangeError: Value not in range: 9
[+1391 ms] "flutter run" took 1,490ms.
[   +5 ms] pub finished with exit code 2
[   +1 ms] 
           #0      throwToolExit (package:flutter_tools/src/base/common.dart:14:3)
           #1      _DefaultPub.interactively (package:flutter_tools/src/dart/pub.dart:375:7)
           <asynchronous suspension>
           #2      PackagesForwardCommand.runCommand (package:flutter_tools/src/commands/packages.dart:260:15)
           #3      FlutterCommand.verifyThenRunCommand (package:flutter_tools/src/runner/flutter_command.dart:977:18)
           <asynchronous suspension>
           #4      FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:836:33)
           <asynchronous suspension>
           #5      FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart)
           #6      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:29)
           #7      _rootRun (dart:async/zone.dart:1190:13)
           #8      _CustomZone.run (dart:async/zone.dart:1093:19)
           #9      _runZoned (dart:async/zone.dart:1630:10)
           #10     runZoned (dart:async/zone.dart:1550:10)
           #11     AppContext.run (package:flutter_tools/src/base/context.dart:149:18)
           #12     FlutterCommand.run (package:flutter_tools/src/runner/flutter_command.dart:825:20)
           #13     CommandRunner.runCommand (package:args/command_runner.dart:197:27)
           #14     FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:335:21)
           #15     _rootRunUnary (dart:async/zone.dart:1198:47)
           #16     _CustomZone.runUnary (dart:async/zone.dart:1100:19)
           #17     _FutureListener.handleValue (dart:async/future_impl.dart:143:18)
           #18     Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:696:45)
           #19     Future._propagateToListeners (dart:async/future_impl.dart:725:32)
           #20     Future._completeWithValue (dart:async/future_impl.dart:529:5)
           #21     Future._asyncCompleteWithValue.<anonymous closure> (dart:async/future_impl.dart:567:7)
           #22     _rootRun (dart:async/zone.dart:1190:13)
           #23     _CustomZone.run (dart:async/zone.dart:1093:19)
           #24     _CustomZone.runGuarded (dart:async/zone.dart:997:7)
           #25     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1037:23)
           #26     _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
           #27     _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
           #28     _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:118:13)
           #29     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:169:5)
           
           
[   +6 ms] ensureAnalyticsSent: 0ms
[   +2 ms] Running shutdown hooks
[        ] Shutdown hooks complete
[   +3 ms] exiting with code 2

flutter doctor -v

[✓] Flutter (Channel unknown, 1.22.6, on macOS 11.2.3 20D91 darwin-x64, locale en-GB)
    • Flutter version 1.22.6 at /Users/marslab/flutter
    • Framework revision 9b2d32b605 (4 months ago), 2021-01-22 14:36:39 -0800
    • Engine revision 2f0af37152
    • Dart version 2.10.5

 
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at /Users/marslab/Library/Android/sdk
    • Platform android-30, build-tools 30.0.3
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 12.5)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.5, Build version 12E262
    • CocoaPods version 1.10.1

[!] Android Studio (version 4.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)

[✓] VS Code (version 1.56.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.22.0

[✓] Connected device (1 available)
    • iPhone 12 Pro Max (mobile) • 24E54E56-FF22-4F1F-B7CD-05560BA2C856 • ios • com.apple.CoreSimulator.SimRuntime.iOS-14-5 (simulator)

! Doctor found issues in 1 category.

Generate ARB file from code

I saw on intl_translation you were posting you can be used as replacement of that package.
I'm wondering if this package can be used to generate ARB files from code like I'm doing with intl_translation, as it's the part missing for me.
Thanks

Feature request: Return "Message" for generated code instead of just the String

First of all thank you for this plugin, this is really awesome!
In some cases I need the key name from the translations. I would like to have an object that stores this additionally. Enclosed is an example of how I imagine this:

// the class
class Message{
   String text;//Happy new Year 🥳

   String name; //happy_new_year

   @override 
   String toString()=>return text; 
} 

// generated code l10n example
Message get happy_new_year {
    return Intl.message(
      'Happy new Year 🥳',
      name: 'happy_new_year',
      desc: '',
      args: [],
    );
  }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.