Skip to content

Commit

Permalink
v1.0.31
Browse files Browse the repository at this point in the history
- ability to change default dart format line length on file generation on trconfig.yaml
- small compatibility fixes for latest flutter / intl.
- fix and remove "Translation" generated code when not using `use_maps` or `output_json_template` to avoid missing
  references in code generation (needs extra testing).
  • Loading branch information
roipeker committed Nov 3, 2023
1 parent 38b7577 commit 65bb60b
Show file tree
Hide file tree
Showing 6 changed files with 174 additions and 88 deletions.
71 changes: 55 additions & 16 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,108 +1,143 @@
## [1.0.31]

- ability to change default dart format line length on file generation on trconfig.yaml
- small compatibility fixes for latest flutter / intl.
- fix and remove "Translation" generated code when not using `use_maps` or `output_json_template` to avoid missing
references in code generation (needs extra testing).

## [1.0.29]

- add another override to posix, trying to comply with dcli dependencies.

## [1.0.28]

- upgrade to Dart SDK 3.1.0
- upgrade dependencies.

## [1.0.27]
- upgrade dependencies to work on latest Dart version (^3.0.1).

- upgrade dependencies to work on latest Dart version (^3.0.1).
- upgrade sdk, packages and fix lint issues

## [1.0.26]

- fix posix path issue (plutil cli call on macos when absolute paths have spaces)
- improved `fts extract`, now skips captured text that's only number, a variable, or a group of chars that have no grapheme (in any charset).
- improved `fts extract`, now skips captured text that's only number, a variable, or a group of chars that have no
grapheme (in any charset).
- add locales to build.gradle resConfigs and android:localeConfig for Android 33+
- added missing language codes from https://cloud.google.com/translate/docs/languages
- added language code sanity check for the GoogleTranslate formula. (full Locales headers are supported now).

## [1.0.25]

- internal fix to check if its running locally in dev mode.
- fix for Windows shell. (thanks @IsmailAlamKhan)
- fixes on `Fts` when loading from json.

## [1.0.24]

- put back dependencies constrains for release.
- put back `fts upgrade` code.

## [1.0.23]

- fix bug with empty `param_output_pattern` and `Fts.tr(namedArgs:)`
- added `fts extract --exclude path1,pathN` to exclude paths from capture.
- added `fts extract --clean` to remove duplicated records.
- added `Fts.useMasterTextAsKey` to use master text as key for translation, for example `"Hello".tr()`
- added `Fts.onSystemLocaleChanged` notifier, receives the events when the window detects a locale change (like on Android 13)
- added `Fts.onSystemLocaleChanged` notifier, receives the events when the window detects a locale change (like on
Android 13)
- change pubspec dependencies to NOT force any constrains (and avoid errors on flutter pub get)
- cleaned up code.
- renamed SimpleLangPicker to LangPickerMaterial and added LangPickerCupertino

## [1.0.22]

- fix generated dart files format.
- made "run" the default command when no arguments are passed.
- add support for dev_dependencies.
- add support to read the configuration (key `fts:`) from pubspec.
- add support to read the configuration PATH (key `fts: "path.yaml"`) from pubspec.
- fix some code formatting.
- add support for auto-include json assets folder in pubspec.flutter.assets
- add `Fts` (and utils) to quickly test the internationalization in your app. `output_fts_utils: true` in the configuration.
- add `Fts` (and utils) to quickly test the internationalization in your app. `output_fts_utils: true` in the
configuration.
- add support for `FTS_CREDENTIALS` environment variable.
- hide vars files, rename `vars.lock` to `.vars.lock`
- when `Fts` is used (.tr() extension), you can specify `fts_utils_args_pattern: "%s"` for not-named variables.
- add support for linked keys in vars, in the format {{@:title}}, fts does not include `param_output_pattern` in those cases.
- when `Fts` is used (.tr() extension), you can specify `fts_utils_args_pattern: "%s"` for not-named variables.
- add support for linked keys in vars, in the format {{@:title}}, fts does not include `param_output_pattern` in those
cases.
- add support to resolve linked keys in `Fts` at runtime.
- add support to resolve linked keys at build time (add to root config `resolve_linked_keys: true`).


## [1.0.21]

- Fix: .arb variables not being generated.

## [1.0.20]

- added CLI check and warning for Sheet locale to avoid potential errors with the formula.
- updated README.

## [1.0.19]

- updated to dart sdk 2.17.
- removed auto check for upgrade version.
- fixed some styling for text in ANSI color output.

## [1.0.18+39]

- improved code generation to match styling on latest `flutter_lints` in Flutter 2.5
- make TKeys generation camelCase, and ensures no fields ends up private, or illegal (starts with number).
- make TKeys generation camelCase, and ensures no fields ends up private, or illegal (starts with number).
- updated all dependencies to latest versions.

## [1.0.17+36]

- improved README.md

## [1.0.17+35]
- add support to unwrap long texts `$ref: file.txt`, extension has to be **.txt**. This allows to have long multiline (html/markup) in a plain text file, instead of doing it inside the yaml.

- add support to unwrap long texts `$ref: file.txt`, extension has to be **.txt**. This allows to have long multiline (
html/markup) in a plain text file, instead of doing it inside the yaml.

## [1.0.16+34]
- remove type matching for optionalParameters in arb generation.

- remove type matching for optionalParameters in arb generation.
This avoids issues with the main Type
Example: `double money` isn't casting `decimalDigits` > `{{money:double:currency(name:"Euro",symbol:"€",decimalDigits:2)}}`
Example: `double money` isn't
casting `decimalDigits` > `{{money:double:currency(name:"Euro",symbol:"€",decimalDigits:2)}}`

## [1.0.15+33]

- readme fixes.
- fix for locale key in `LangVo`.
- improved `SimpleLangPicker` ui.

## [1.0.15+32]

- dart format.

## [1.0.15+31]

- preparing release for pub.dev

## [1.0.14+30]

- fixed `fts --version` for local development.
- added global catch() for sheet errors, to provide in the future better hints on the errors and possible solutions.
- changed some wording on the error messages.
- made some preparations files for a future init command.
- custom arb placeholders are STILL broken. Should be revisit asap.

## [1.0.14+29]

- Fixed the upgrade `fts upgrade` command.
- Fix sorting of export file under [dart:output_dir]

## [1.0.14+27]

- add `fts run --watch` to keep listening for file system changes in the config file and the directory that holds your master strings (entry_file parent folder).
- add `fts run --watch` to keep listening for file system changes in the config file and the directory that holds your
master strings (entry_file parent folder).
- [LangVo.flagChar] to read the flag "emojis" if supported by the system.
- add default dart exports for [config.dart.output_dir] file.
- add dart reserved words checking (and replacer) for the master strings tag, when generating TKeys files.
Expand Down Expand Up @@ -146,7 +181,8 @@
- new arguments inside variables.
- fixes Locale canonicalization, now uses the Flutter way: en_US instead of en-us
- fixes Intl generator error when only languageCode_countryCode is defined (without the languageCode only fallback).
- Much improved RegExp for variable detection in GoogleSheet cells, when GoogleTranslate corrupts the format breaking the generated code.
- Much improved RegExp for variable detection in GoogleSheet cells, when GoogleTranslate corrupts the format breaking
the generated code.
- Automatic iOS Info.plist sync with locales (only macos).

## [1.0.8+17]
Expand All @@ -162,11 +198,13 @@

## [1.0.7+15]

- improved `extract` with --ext and --permissive options to search for more file types, and allow capturing strings without spaces.
- improved `extract` with --ext and --permissive options to search for more file types, and allow capturing strings
without spaces.
- new [intl:enabled:true] option in trconfig.yaml to output `arb` files in lib.
- other minor improvements. Still need to add docs and test new features.

argParser.addOption('ext', defaultsTo: 'dart', abbr: 'e', help: 'Comma separated list of allowed file extensions types to analyze for strings.');
argParser.addOption('ext', defaultsTo: 'dart', abbr: 'e', help: 'Comma separated list of allowed file extensions types
to analyze for strings.');
argParser.addFlag('permissive', abbr: 's', help: 'Toggles permissive mode, capturing strings without spaces in it.');

## [1.0.6+15]
Expand Down Expand Up @@ -197,7 +235,8 @@ argParser.addFlag('permissive', abbr: 's', help: 'Toggles permissive mode, captu
- changed cli program to `fts`
- clean docs.
- added `AppLocales.of(locale)` to search for `LangVo` (contains native and english name of the locale).
- added `toString()` methods in Keys classes... that returns the keys 'path.' (might be useful to resolve gender, plurals based on the base key string).
- added `toString()` methods in Keys classes... that returns the keys 'path.' (might be useful to resolve gender,
plurals based on the base key string).

## [1.0.4]

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ We have 2 flavours:

```yaml
dev_dependencies:
flutter_translation_sheet: ^1.0.22
flutter_translation_sheet: ^1.0.31
```
use the latest version of the package:
Expand Down
37 changes: 32 additions & 5 deletions lib/src/io/dart_gen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,28 @@ void createFtsUtilsFile() {
fileContent = fileContent.replaceAll('##loadJsonFallback', '');
fileContent = fileContent.replaceAll('##loadJsonMethod', '');
fileContent = fileContent.replaceAll('##decodeTranslationMethod', '');
resolveTranslationCode = kResolveTranslationMap;
if (config.useDartMaps == false) {
resolveTranslationCode = kResolveTranslationJson;
} else {
resolveTranslationCode = kResolveTranslationMap;
}
}

/// only when using `keys_id: true`
fileContent = fileContent.replaceAll(
'##translationMapUtils',
config.validTKeyFile ? kTrKeysUtils : '',
);
fileContent = fileContent.replaceAll(
'##ftsStringExtensionSource',
config.validTKeyFile ? kFtsStringExtensionSource : '',
);

// --
fileContent =
fileContent.replaceAll('##resolveTranslations', resolveTranslationCode);

// --
fileContent = fileContent.replaceFirst(
'##argsPattern',
config.paramFtsUtilsArgsPattern,
Expand Down Expand Up @@ -247,14 +263,18 @@ String createTranslationFile(
''';
}

translateClassString = '''
// only applies when `use_maps: true`
// if (config.useDartMaps) {
if (config.validTKeyFile) {
translateClassString = '''
//ignore: avoid_classes_with_only_static_members
abstract class $tClassName {
$tLocalesCode
${getCodeMapLocaleKeysToMasterText(tClassName)}
}''';
}

// final _transImportsString = transImports.join('\n');
// $_transImportsString
Expand Down Expand Up @@ -555,9 +575,16 @@ void runPubGet() {
void formatDartFiles() {
/// format dart files.
if (config.validTranslationFile || config.validTKeyFile) {
if (which('flutter').found) {
// 'dartfmt -w ${config.dartOutputDir}'.start(
'flutter format --fix ${config.dartOutputDir}'.start(
var lineLength = '';
if (config.dartFormatLineLength > 0) {
lineLength = '--line-length ${config.dartFormatLineLength}';
}
final cmd = 'dart format --fix $lineLength ${config.dartOutputDir}';

print('running dart format...');
print(cmd);
if (which('dart').found) {
cmd.start(
// workingDirectory: config.dartOutputDir,
detached: true,
runInShell: true,
Expand Down
3 changes: 3 additions & 0 deletions lib/src/io/env_parser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ void loadEnv({
config.dartOutputFtsUtils = doc['dart']['output_fts_utils'] ?? false;
config.dartTKeysId = doc['dart']?['keys_id'] ?? '';
config.useDartMaps = doc['dart']?['use_maps'] ?? false;
config.dartFormatLineLength = doc['dart']?['format_line_length'] ?? 0;
config.dartTranslationsId = doc['dart']?['translations_id'] ?? '';
config.paramOutputPattern = doc['param_output_pattern'] ?? '{*}';
config.resolveLinkedKeys = doc['resolve_linked_keys'] ?? false;
Expand Down Expand Up @@ -279,6 +280,8 @@ class EnvConfig {
// param_output_pattern
bool useDartMaps = false;

int dartFormatLineLength = 0;

String get iosDirPath {
return p.canonicalize(p.join(configProjectDir, 'ios'));
}
Expand Down
Loading

0 comments on commit 65bb60b

Please sign in to comment.