slang-i18n / slang

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

Nested strings in interface #191

Closed mjablecnik closed 4 months ago

mjablecnik commented 4 months ago

I have this strings with interface:

distribution_list(interface=DistributionType):
  point:
    title: "Seznam výdejních míst"
    error: "Nastala neočekávaná chyba: Výdejní místa nelze načíst."
    buttons:
      refresh: "Obnovit"
      finish: "OK"
  box:
    title: "Seznam boxů"
    error: "Nastala neočekávaná chyba: Seznam boxů nelze načíst."
    buttons:
      refresh: "Obnovit"
      finish: "Detail"

Into slang.yaml I added: Screenshot 2024-02-05 at 14 55 21

During generation I have this: Screenshot 2024-02-05 at 14 55 49

But generated code looks like this: Screenshot 2024-02-05 at 14 57 32

Screenshot 2024-02-05 at 14 58 28

Can you somehow fix the generated code? Now it doesn't work.

Tienisto commented 4 months ago

Thanks for this issue. This is seems to be not supported yet.

Just a remark: You don't need to specify the interfaces in the config anymore, adding the hints in the i18n file is enough.

Tienisto commented 4 months ago

Fixed in https://github.com/slang-i18n/slang/commit/ba487b798427d8982cb630dca46b3cf572b0499e

You will need to specify the nested interface either via config or in every child:

distribution_list(interface=DistributionType):
  point:
    title: "Seznam výdejních míst"
    error: "Nastala neočekávaná chyba: Výdejní místa nelze načíst."
    buttons(singleInterface=DistributionButton):
      refresh: "Obnovit"
      finish: "OK"
  box:
    title: "Seznam boxů"
    error: "Nastala neočekávaná chyba: Seznam boxů nelze načíst."
    buttons(singleInterface=DistributionButton):
      refresh: "Obnovit"
      finish: "Detail"

or as config (you can then leave out (singleInterface=DistributionButton)):

interfaces:
  DistributionButton:
    attributes:
      - String refresh
      - String finish
Tienisto commented 4 months ago

Published in v3.30.0