Merge branch 'MohiuddinM:master' into master

This commit is contained in:
2026-02-15 22:36:04 +02:00
committed by GitHub
12 changed files with 107 additions and 40 deletions

View File

@@ -1,3 +1,23 @@
## 4.2.4
- fix double digit version parsing for formatter
## 4.2.3
- fix formatter
## 4.2.2
- update dependencies
## 4.2.1
- update readme
## 4.2.0
- upgrade deps
## 4.1.1
- add multi base file support (by [shovelmn12](https://github.com/MohiuddinM/i18n/pull/30))

View File

@@ -1,9 +1,10 @@
# i18n
![tests](https://github.com/MohiuddinM/i18n/workflows/test/badge.svg)
[![pub package](https://img.shields.io/pub/v/i18n.svg)](https://pub.dev/packages/i18n)
Simple internationalization package for Dart and Flutter. This package is a permanent fork of another
internationalization package [https://github.com/fnx-io/i69n]. This package now supports hot reload and is tested on
Simple internationalization package for Dart and Flutter. This package now supports hot reload and
is tested on
latest versions of Flutter.
# Overview

View File

@@ -10,14 +10,14 @@ list(APPEND FLUTTER_FFI_PLUGIN_LIST
set(PLUGIN_BUNDLED_LIBRARIES)
foreach (plugin ${FLUTTER_PLUGIN_LIST})
add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin})
target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin)
list(APPEND PLUGIN_BUNDLED_LIBRARIES $<TARGET_FILE:${plugin}_plugin>)
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
endforeach (plugin)
foreach(plugin ${FLUTTER_PLUGIN_LIST})
add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin})
target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin)
list(APPEND PLUGIN_BUNDLED_LIBRARIES $<TARGET_FILE:${plugin}_plugin>)
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
endforeach(plugin)
foreach (ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST})
add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin})
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries})
endforeach (ffi_plugin)
foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST})
add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin})
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries})
endforeach(ffi_plugin)

View File

@@ -16,7 +16,7 @@ dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^2.0.0
flutter_lints: ^5.0.0
build_runner:
flutter:

View File

@@ -10,14 +10,14 @@ list(APPEND FLUTTER_FFI_PLUGIN_LIST
set(PLUGIN_BUNDLED_LIBRARIES)
foreach (plugin ${FLUTTER_PLUGIN_LIST})
add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin})
target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin)
list(APPEND PLUGIN_BUNDLED_LIBRARIES $<TARGET_FILE:${plugin}_plugin>)
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
endforeach (plugin)
foreach(plugin ${FLUTTER_PLUGIN_LIST})
add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin})
target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin)
list(APPEND PLUGIN_BUNDLED_LIBRARIES $<TARGET_FILE:${plugin}_plugin>)
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
endforeach(plugin)
foreach (ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST})
add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin})
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries})
endforeach (ffi_plugin)
foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST})
add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin})
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries})
endforeach(ffi_plugin)

View File

@@ -1,13 +1,11 @@
// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'dart:io';
import 'dart:math';
import 'package:build/build.dart';
import 'package:dart_style/dart_style.dart';
import 'package:glob/glob.dart';
import 'package:i18n/src/i18n_impl.dart';
import 'package:pub_semver/pub_semver.dart';
import 'package:yaml/yaml.dart';
Builder yamlBasedBuilder(BuilderOptions options) => YamlBasedBuilder();
@@ -83,14 +81,20 @@ class YamlBasedBuilder implements Builder {
var dartContent = generateDartContentFromYaml(objectName, contents);
try {
dartContent = DartFormatter().format(dartContent);
final versionText = Platform.version;
final version = versionText.substring(
0,
versionText.indexOf(' '),
);
final formatter = DartFormatter(languageVersion: Version.parse(version));
dartContent = formatter.format(dartContent);
} on FormatterException {
log.warning(
'Could not format generated output, it might contain errors.',
);
}
var copy = currentFile.changeExtension('.dart');
final copy = currentFile.changeExtension('.dart');
// Write out the new asset.
await buildStep.writeAsString(copy, dartContent);

View File

@@ -1,4 +1,4 @@
import 'package:i18n/i18n.dart';
import '../i18n.dart';
///
/// Quantity category resolver for czech.

View File

@@ -1,4 +1,4 @@
import 'package:i18n/i18n.dart';
import '../i18n.dart';
///
/// Quantity category resolver for english.

View File

@@ -1,5 +1,3 @@
library i18n;
import 'dart:convert';
import 'package:yaml/yaml.dart';
@@ -229,4 +227,3 @@ void renderMapEntries(YamlMap messages, StringBuffer output, String prefix) {
String _renderFileNameError(String name) {
return 'File name can not contain more than 2 "_" characters: \'$name\'';
}

View File

@@ -9,7 +9,7 @@ class Metadata {
final String localeName;
final String languageCode;
Metadata({
const Metadata({
this.parent,
required this.isDefault,
required this.defaultObjectName,
@@ -30,11 +30,55 @@ class Metadata {
languageCode: languageCode,
);
}
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is Metadata &&
runtimeType == other.runtimeType &&
parent == other.parent &&
isDefault == other.isDefault &&
defaultObjectName == other.defaultObjectName &&
defaultFileName == other.defaultFileName &&
objectName == other.objectName &&
localeName == other.localeName &&
languageCode == other.languageCode;
@override
int get hashCode =>
parent.hashCode ^
isDefault.hashCode ^
defaultObjectName.hashCode ^
defaultFileName.hashCode ^
objectName.hashCode ^
localeName.hashCode ^
languageCode.hashCode;
@override
String toString() {
return 'Metadata(parent: $parent, isDefault: $isDefault, defaultObjectName: $defaultObjectName, defaultFileName: $defaultFileName, objectName: $objectName, localeName: $localeName, languageCode: $languageCode)';
}
}
class Translation {
final Metadata metadata;
final YamlMap content;
Translation(this.metadata, this.content);
const Translation(this.metadata, this.content);
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is Translation &&
runtimeType == other.runtimeType &&
metadata == other.metadata &&
content == other.content;
@override
int get hashCode => metadata.hashCode ^ content.hashCode;
@override
String toString() {
return 'Translation(metadata: $metadata, content: $content)';
}
}

View File

@@ -1,4 +1,4 @@
import 'package:i18n/i18n.dart';
import '../i18n.dart';
///
/// Quantity category resolver for russian.

View File

@@ -1,6 +1,6 @@
name: i18n
description: Simple i18n solution for dart and flutter. Uses code generation to generate translations as dart classes. Efficient and works with autocomplete!
version: 4.1.1
version: 4.2.4
homepage: https://github.com/MohiuddinM/i18n
environment:
@@ -9,13 +9,14 @@ environment:
dependencies:
build: ^2.0.0
build_config: ^1.0.0
dart_style: ^2.0.0
dart_style: ^3.0.0
yaml: ^3.0.0
quick_log: ^5.0.0
glob: ^2.0.0
pub_semver: ^2.0.0
dev_dependencies:
lints: ^4.0.0
lints: ^5.0.0
test: ^1.16.8
build_runner: ^2.0.0
build_web_compilers: ^4.0.0