Localization Accountability

How do you keep your team (or yourself) accountable for using localized strings?

I thought their might be a lint rule to help catch string literals but not seeing anything in the lint documentation.

6 Likes

That is a great question. This link allows requesting a new lint rule to be added.

Issue: Add an existing lint to the core or recommended rule set

This link shows how to write a custom lint rule.

How to create a custom lint rule for Flutter

2 Likes

I created an extension getter “tr” so if someone doesn’t feel like being nice, it can be extracted and replaced later through some regex. (I’m using slang/slang_flutter packages)

extension StringExtensions on String {
  String get tr => this;
}

After trying several options, I ended up using this custom lint package-
https://pub.dev/packages/l10n_lint

2 Likes

@cardin I’m in the process of creating an IDE extension/plugin (VS Code and IntelliJ/Android Studio) that does that. And you can even mark strings that are not to be translated.

You can see some screenshots here: MyText.ai and if you have some feature ideas on how to improve this plugin, let me know.

Note this is a paid service, but the plugin usage will be free (forever).

2 Likes

For those looking for a great AI translation package, I would recommend
https://pub.dev/packages/arb_translate. You can link your OpenAI or Gemini account to generate translations.

That’s great actually! Will there be a way to declare a naming convention for variables?

1 Like

By “variables” you mean the translation identifiers? For example, if you want to translate Text("Hello, there") the plugin will replace this automatically with Text(greetings). The AI chooses the name of the identifier (in this case greetings), but yes, it could easily allow giving instructions about naming conventions to the AI.

Also note, that depends on the localization package you’re using. For example, with i18n_extension | Flutter package you don’t need identifiers, but only to add .i18n after the String. So this example would become Text("Hello, there".i18n). MyText.ai and the free plugin will support the 10 most used localization packages in pub.dev.

Interesting solution. I tried to join the list but there was a misredirection.

Really? The waitlist button should open your email reader (Gmail or whatever). Please, where did it misdirect to?

Yes, by variables I meant the identifiers. Also, I use slang as it supports type-safety and CSV format.

What would happen if the AI chose a duplicate identifier? Or if a String is re-used?

Chrome refused to open gmail or anything and let a blank screen.

Ok Robert, thanks for letting me know! I just fixed this by adding a proper waitlist service. Please, would you mind trying again when you have the time? Here is the waitlist link.

1 Like

It keeps track of all previously used identifiers, so it won’t choose duplicates. If a string is reused, it considers how and where it is used, including the Dart file, to ensure it differentiates appropriately. The idea is that you don’t have to think about it, it should just work.

Less friction => more inscriptions
It worked well Marcelo.

1 Like