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

It does not work as expected on value based texts #2

Closed amin79 closed 11 months ago

amin79 commented 11 months ago

This is the text in english:

"cancelationDay": "{count, select, 1{Free cancelation {count} day before} other{Free cancelation {count} days before}}",

and this is what I get when it's translated to German:

"cancelationDay": "{count, select, 1{Kostenlose Stornierung{count} Tage vorher} other{Kostenlose Stornierung count} Tage vorher}}",

as you see in the translated text in "other", "count" shall be inside {} but its not. It's the same for all other languages. it shall be {count} but it's count} Also it does not respect the spaces. cancelation {count} and in translated it's Stornierung{count}

auto_translator: ^1.1.0

theLee3 commented 11 months ago

Thank you @amin79. The ARB format for variables changed since this package was written, and an update is needed to handle certain scenarios. I am working on the fix now. Stay tuned.

theLee3 commented 11 months ago

@amin79 Please update the auto_translator dependency in pubspec.yaml to the following:

auto_translator:
    git: 
      url: https://github.com/theLee3/flutter_auto_translator.git

This will pull the 2.0.0 release candidate that I just pushed to Github. I have to update the docs and example before publishing. I would love to know if it resolves your issue.

amin79 commented 11 months ago

Hello. Thank you for your work. But I got following error:

Unhandled exception: type '_Map<String, dynamic>' is not a subtype of type 'String'

0 _buildTemplate (package:auto_translator/src/main.dart:206:53)

1 _translate (package:auto_translator/src/main.dart:117:33)

2 runWithArguments (package:auto_translator/src/main.dart:51:11)

theLee3 commented 11 months ago

Thank you for the feedback @amin79. Please run flutter clean then flutter pub get and try again. You should see auto_translator v2.0.0 on the command when it runs to confirm that it is the latest build.

amin79 commented 11 months ago

@theLee3 I did it but still was V1. Then I deleted the .pub-cache folder and now I get this error:

Could not find a file named "pubspec.yaml" in https://github.com/theLee3/flutter_auto_translator.git

amin79 commented 11 months ago

I tried once more and was able to get it run finally. Now get this error:

Translating from en to ru...Unhandled exception: RangeError (index): Invalid value: Not in inclusive range 0..34: -1

0 _StringBase.[] (dart:core-patch/string_patch.dart:258:41)

1 Translator._removeAddedWhitespace (package:auto_translator/src/translator.dart:130:20)

2 Translator.translate (package:auto_translator/src/translator.dart:59:15)

#3 _translate (package:auto_translator/src/main.dart:168:21) #4 runWithArguments (package:auto_translator/src/main.dart:49:5) BTW. it seems that the problem I had for translation is solved in this version.
theLee3 commented 11 months ago

BTW. it seems that the problem I had for translation is solved in this version.

Well at least there's that! 🥳

I think I tracked down the last issue. One edge case unaccounted for.

Please run flutter pub upgrade and try again. Hopefully this will be the last time🤞

Ensure that the version printed to the console is 2.0.0+1.

amin79 commented 11 months ago

Hi. I tested it. Everything works :) Thank you for your support

theLee3 commented 11 months ago

Awesome! Thank you so much for your help & feedback @amin79. Version 2.0.0 is now available on pub.dev and can be added as normal via pubspec.yaml.