theLee3 / flutter_auto_translator

A command-line tool to translate ARB files.
BSD 3-Clause "New" or "Revised" License
8 stars 5 forks source link

Update tanslator.dart and support dynamic templateFilename. #1

Closed w-rui closed 1 year ago

w-rui commented 1 year ago
  1. support dynamic templateFilename of type in RegExp: r'^[a-zA-Z0-9]+[a-zA-Z0-9-]+.arb$'.

template file name can be: intl_en.arb, intl_en_US.arb, app_zh.arb an so on.

Core codes here:

    final arbDir = _config['arb-dir'] as String? ?? "lib/l10n";
    final templateFilename = _config['template-arb-file'] as String? ?? "app_en.arb";

    final source = templateFilename.substring(templateFilename.indexOf(RegExp(r'[-_]')) + 1, templateFilename.indexOf('.arb'));
    final name = templateFilename.substring(0, templateFilename.indexOf(RegExp(r'[-_]')));
theLee3 commented 1 year ago

Thanks for your pull request. It looks good. I am going to update the tests and docs to account for the changes shortly and merge.

theLee3 commented 1 year ago

Included in version 1.1.0 Thanks @w-rui