Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ All notable changes to the "flutter-intl" extension will be documented in this f
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 2.8.13 - Unreleased

- Fix language overrides ([#19](https://github.com/localizely/intl_utils/issues/19))

## 2.8.12 - 2025-09-10

- Update `analyzer` dependency
Expand Down Expand Up @@ -70,7 +74,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## 2.8.0 - 2022-11-15

- Update `analyzer` and `lints` dependencies
- Update `analyzer` and `lints` dependencies ([#91](https://github.com/localizely/intl_utils/issues/91))

## 2.7.0 - 2022-07-07

Expand Down
2 changes: 1 addition & 1 deletion bin/generate.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
library intl_utils;
library;

import 'package:intl_utils/intl_utils.dart';
import 'package:intl_utils/src/generator/generator_exception.dart';
Expand Down
2 changes: 1 addition & 1 deletion bin/localizely_download.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
library intl_utils;
library;

import 'dart:io';

Expand Down
2 changes: 1 addition & 1 deletion bin/localizely_upload_main.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
library intl_utils;
library;

import 'dart:io';

Expand Down
2 changes: 1 addition & 1 deletion lib/intl_utils.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
library intl_utils;
library;

export 'src/generator/generator.dart';
5 changes: 5 additions & 0 deletions lib/src/generator/label.dart
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ class Label {
' name: \'$name\',',
' desc: \'$description\',',
' args: [],',
' locale: localeName,',
' );',
' }',
].join('\n');
Expand All @@ -352,6 +353,7 @@ class Label {
' name: \'$name\',',
' desc: \'$description\',',
' args: [${_generateDartMethodArgs(args)}],',
' locale: localeName,',
' );',
' }',
].join('\n');
Expand All @@ -370,6 +372,7 @@ class Label {
' name: \'$name\',',
' desc: \'$description\',',
' args: [${_generateDartMethodArgs(args)}],',
' locale: localeName,',
' );',
' }',
].join('\n');
Expand All @@ -388,6 +391,7 @@ class Label {
' name: \'$name\',',
' desc: \'$description\',',
' args: [${_generateDartMethodArgs(args)}],',
' locale: localeName,',
' );',
' }',
].join('\n');
Expand All @@ -409,6 +413,7 @@ class Label {
' name: \'$name\',',
' desc: \'$description\',',
' args: [${_generateDartMethodArgs(args)}],',
' locale: localeName,',
' );',
' }',
].join('\n');
Expand Down
13 changes: 8 additions & 5 deletions lib/src/generator/templates.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ String generateL10nDartFileContent(
]) {
return """
// GENERATED CODE - DO NOT MODIFY BY HAND
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';${otaEnabled ? '\n${_generateLocalizelySdkImport()}' : ''}
import 'intl/messages_all.dart';
Expand All @@ -23,10 +24,12 @@ import 'intl/messages_all.dart';
// ignore_for_file: avoid_redundant_argument_values, avoid_escaping_inner_quotes

class $className {
$className();
$className(this.localeName);

static $className? _current;

/// It is strongly discouraged to use this instance since it can easily
/// lead to non-determinism. Use [of] or [maybeOf] instead.
static $className get current {
assert(_current != null, 'No instance of $className was loaded. Try to initialize the $className delegate before accessing $className.current.');
return _current!;
Expand All @@ -39,11 +42,9 @@ class $className {
final name = (locale.countryCode?.isEmpty ?? false) ? locale.languageCode : locale.toString();
final localeName = Intl.canonicalizedLocale(name);${otaEnabled ? '\n${_generateMetadataSetter()}' : ''}
return initializeMessages(localeName).then((_) {
Intl.defaultLocale = localeName;
final instance = $className();
final instance = $className(localeName);
$className._current = instance;

return instance;
return SynchronousFuture<$className>(instance);
});
}

Expand All @@ -56,6 +57,8 @@ class $className {
static $className? maybeOf(BuildContext context) {
return Localizations.of<$className>(context, $className);
}

final String localeName;
${otaEnabled ? '\n${_generateMetadata(labels)}\n' : ''}
${labels.map((label) => label.generateDartGetter()).join("\n\n")}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/src/intl_translation/extract_messages.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
/// Note that this does not understand how to follow part directives, so it
/// has to explicitly be given all the files that it needs. A typical use case
/// is to run it on all .dart files in a directory.
library extract_messages;
library;

// ignore_for_file: implementation_imports

Expand Down
2 changes: 1 addition & 1 deletion lib/src/intl_translation/generate_localized.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
///
/// An example of usage can be found
/// in test/message_extract/generate_from_json.dart
library generate_localized;
library;

import 'package:intl/intl.dart';
import 'dart:convert';
Expand Down
2 changes: 1 addition & 1 deletion lib/src/intl_translation/src/icu_parser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

/// Contains a parser for ICU format plural/gender/select format for localized
/// messages. See extract_to_arb.dart and make_hardcoded_translation.dart.
library icu_parser;
library;

import 'package:petitparser/petitparser.dart';

Expand Down
2 changes: 1 addition & 1 deletion lib/src/intl_translation/src/intl_message.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
/// This representation isn't used at runtime. Rather, we read some format
/// from a translation file, parse it into these objects, and they are then
/// used to generate the code representation above.
library intl_message;
library;

// ignore_for_file: implementation_imports

Expand Down
2 changes: 1 addition & 1 deletion lib/src/utils/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ bool isValidLocale(String value) => RegExp(
).hasMatch(value);

bool isValidPath(String value) =>
RegExp(r'^(?:[A-Za-z]:)?([\/\\]{0,2}\w*)+$').hasMatch(value);
RegExp(r'^(?:[A-Za-z]:)?([/\\]{0,2}\w*)+$').hasMatch(value);

bool isValidDownloadEmptyAsParam(String value) =>
RegExp(r'^(empty|main|skip)$').hasMatch(value);
Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: intl_utils
description: intl_utils is a dart library that generates Dart localization code from ARB file. Generated code relies on Intl library.
version: 2.8.12
version: 2.8.13
homepage: https://github.com/localizely/intl_utils

environment:
Expand All @@ -19,6 +19,6 @@ dependencies:

dev_dependencies:
build_runner: ^2.0.6
lints: ^4.0.0
lints: ^5.0.0
mockito: ^5.5.1
test: ^1.16.0