slang-i18n / slang

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

fix: exclude comments from analysis during the execution of 'analyze' #200

Closed nikaera closed 3 months ago

nikaera commented 3 months ago

Currently, commented-out content is also being included as part of the analysis, so if the following code is present, the translation was considered to be in use. 💭

//...
  @override
  Widget build(BuildContext context) {
    // get t variable, will trigger rebuild on locale change
    // otherwise just call t directly (if locale is not changeable)
    final t = Translations.of(context);

    return Scaffold(
      appBar: AppBar(
        // NOTE: Due to the presence of Text(t.mainScreen.title) in the comment, it was mistakenly considered to be in use.
        title: Text(""), // Text(t.mainScreen.title),
      ),
//...

As the behavior was not intended to be as such, commented-out content has been modified to be excluded from analysis when executing the analyze command. ✅

Tienisto commented 3 months ago

Thank you. I have adjusted the regex by adding dotAll to handle block comments.

nikaera commented 3 months ago

@Tienisto Wow, thank you for the fixes! 🙏✨

nikaera commented 3 months ago

I'll make sure to search for relevant test code and write automated tests if there isn't any already from now on. 🤖 💭