lang_table 0.2.0 copy "lang_table: ^0.2.0" to clipboard
lang_table: ^0.2.0 copied to clipboard

lang_table is a dart plugin to generate string files from a source. Use a table to manage all multi-language resources.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:lang_table_example/generated/i18n.dart';
import 'package:flutter_localizations/flutter_localizations.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  int index = 0;
  List<Locale> localeList = [Locale('en'), Locale('ja'), Locale('zh', 'TW')];

  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        localizationsDelegates: [
          S.delegate,
          GlobalMaterialLocalizations.delegate,
          GlobalWidgetsLocalizations.delegate
        ],
        supportedLocales: S.delegate.supportedLocales,
        locale: localeList[index],
        home: Builder(
          builder: (BuildContext context) {
            return Scaffold(
                appBar: AppBar(
                  title: Text(S.of(context).locale),
                ),
                body: Center(
                    child: Column(
                      children: <Widget>[
                        Text(S.of(context).locale),
                        Text(S.of(context).simpleMessage),
                        Text(S.of(context).messageWithParams('developer')),
                        Text(S.of(context).pluralMessage(1, 'KingWu')),
                        Text(S.of(context).pluralMessage(10, 'KingWu')),
                        Text(S.of(context).genderMessage('male', 'KingWu')),
                        Text(S.of(context).genderMessage('female', 'KingWu')),
                        Text(S.of(context).genderMessage('other', 'KingWu'))
                      ],
                    )
                ),
                floatingActionButton: FloatingActionButton(
                  onPressed: () {
                    switchLang();
                  },
                  child: Icon(Icons.add),
                )
            );
          },
        )

    );
  }

  void switchLang(){
    setState(() {
      index++;
      if(index >= localeList.length){
        index = 0;
      }
    });

  }
}
1
likes
40
pub points
7%
popularity

Publisher

unverified uploader

lang_table is a dart plugin to generate string files from a source. Use a table to manage all multi-language resources.

Repository (GitHub)
View/report issues

License

BSD-2-Clause (LICENSE)

Dependencies

ansicolor, args, http, path

More

Packages that depend on lang_table