slang-i18n / slang

Type-safe i18n for Dart and Flutter
https://pub.dev/packages/slang
MIT License
419 stars 36 forks source link

Setting base_locale #204

Closed hantrungkien closed 3 months ago

hantrungkien commented 3 months ago

Hi @Tienisto, I have 2 translate files

strings_en-US.i18n.json strings_ja-JP.i18n.json

and slang.yaml

base_locale: en-US
fallback_strategy: base_locale
input_directory: lib/i18n
input_file_pattern: .i18n.json
output_directory: lib/i18n
output_file_name: strings.g.dart

Here is log after run dart run slang

Scanning translations...

 (base) en-US -> lib/i18n/strings_en-US.i18n.json
        ja-JP -> lib/i18n/strings_ja-JP.i18n.json

But here is log after run dart run build_runner build --delete-conflicting-outputs

Translation file for base locale "en" not found.
  slang: ^3.30.1
  slang_flutter: ^3.30.0
  slang_build_runner: ^3.30.0

Could you please share a solution to bypass it? Thanks a lot!

hantrungkien commented 3 months ago

After I moved the configurations from slang.yaml => build.yaml then it was correct. Maybe we should prioritize the configuration scanning order build.yaml => slang.yaml.

Tienisto commented 3 months ago

Hello, build_runner only knows build.yaml. It is also stated in the documentation that if you use build_runner, you have to use build.yaml.

slang.yaml is just a convenience for those who don't use build_runner.