channdara / flutter_localization

BSD 3-Clause "New" or "Revised" License
10 stars 17 forks source link

how to pass a paramter to be added to strings localized like "Here is the number:$number" #8

Closed EgHubs closed 9 months ago

EgHubs commented 9 months ago

I use these two classes for localization in flutter following this article setup.

import 'package:flutter/cupertino.dart';

abstract class Languages {
  final String? extra;

  Languages({this.extra});
  static Languages? of(BuildContext context, {String? extra}) {
    return Localizations.of<Languages>(context, Languages);
  }
String get text199;
}

and this LanguageEn:

import 'languages.dart';

class LanguageEn extends Languages
{
  LanguageEn({String? extra}) : super(extra: extra);
  @override
String get text199 => "Update data($extra)";
}

when I pass this extra parameter I get null "Update data(null)" in whatever language I'm in

Languages.of(context,extra: "$activeID")!.text199),

but when I directly select a language class and do this it works and I get the number and not null "Update data(4)"

LanguageEn(extra: "$activeID").text199),

how to pass dynamic strings with this package?

channdara commented 9 months ago

Hello. I think you have reported the issue to the wrong package. This package is flutter_localization, the package you are using is the Flutter SDK flutter_localizations.