i18n_plus 1.1.0 copy "i18n_plus: ^1.1.0" to clipboard
i18n_plus: ^1.1.0 copied to clipboard

Helps to implement different languages in your app with ease.

example/example.dart

import 'package:flutter/material.dart';
import 'package:i18n_plus/i18n.dart';
import 'package:i18n_plus/i18nLanguageset.dart';
import 'package:i18n_plus/i18nMap.dart';
import 'package:i18n_plus/i18nText.dart';

main() {
  runApp(MaterialApp(home: Example()));
}

class Example extends StatefulWidget {
  Example({Key? key}) : super(key: key);
  _ExampleState createState() => _ExampleState();
}

class _ExampleState extends State<Example> {
  I18NMap map = I18NMap([
    Langaugeset.fromJsonString(Locale('zh', 'CN'), "{\"greeting\":\"您好\"}"),
    Langaugeset(Locale('en', 'Us'), {"greeting": "Hello"}),
    Langaugeset(Locale('de', 'De'), {"greeting": "Hallo"}),
    Langaugeset(Locale('fr', 'Fr'), {"greeting": "Bonjour"})
  ]);
  I18N i18n = I18N();

  @override
  void initState() {
    i18n.seti18nMap(map);
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        body: Column(children: [
      Container(
          child: I18NText(
        i18nKey: "greeting",
        additionalString: " Flutter Dev!",
      )),
      DropdownButton<Locale>(
        items: i18n.allLocale()!.map((Locale value) {
          return new DropdownMenuItem<Locale>(
            value: value,
            child: new Text(value.toLanguageTag()),
          );
        }).toList(),
        onChanged: (value) {
          i18n.setCurrentLocale(value);
        },
      )
    ]));
  }
}
1
likes
110
pub points
0%
popularity

Publisher

verified publisherljb-dev.com

Helps to implement different languages in your app with ease.

Homepage

Documentation

API reference

License

BSD-3-Clause (LICENSE)

Dependencies

flutter

More

Packages that depend on i18n_plus