csv_localizations 2.2.0+9 copy "csv_localizations: ^2.2.0+9" to clipboard
csv_localizations: ^2.2.0+9 copied to clipboard

A minimal CSV localization package built on LocalizationsDelegate.

example/lib/main.dart

import 'package:csv_localizations/csv_localizations.dart';
import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';

import 'string_ext.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      localizationsDelegates: const [
        ...GlobalMaterialLocalizations.delegates,
        CsvLocalizationsDelegate(
          path: 'assets/translations.csv',
          configurations: CsvLocalizationsConfigurations(
            eol: '\n',
            fieldDelimiter: ',',
            shouldParseNumbers: true,
          ),
        ),
      ],
      supportedLocales: const [
        Locale('en', 'GB'),
        Locale('en', 'US'),
        Locale('en'),
        Locale('nb'),
      ],
      theme: ThemeData(
        primarySwatch: Colors.blue,
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: const MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key}) : super(key: key);

  @override
  MyHomePageState createState() => MyHomePageState();
}

class MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('csv_localizations'),
      ),
      body: Column(
        mainAxisAlignment: MainAxisAlignment.start,
        crossAxisAlignment: CrossAxisAlignment.start,
        children: <Widget>[
          Text(
            'Hi'.tr,
            style: const TextStyle(
              fontSize: 24,
            ),
          ),
          Image.asset(
            'my_img'.tr,
            width: 64,
            height: 64,
            fit: BoxFit.contain,
            filterQuality: FilterQuality.none,
          ),
          Text(
            'Multiline'.tr,
            style: const TextStyle(
              fontSize: 24,
            ),
          ),
          Text(
            'num'.numValue.toString(),
            style: const TextStyle(
              fontSize: 24,
            ),
          ),
          Text(
            'int'.intValue.toString(),
            style: const TextStyle(
              fontSize: 24,
            ),
          ),
          Text(
            'double'.doubleValue.toString(),
            style: const TextStyle(
              fontSize: 24,
            ),
          ),
          Text(
            'someStringWeHaventTranslatedYet'.tr,
            style: const TextStyle(
              fontSize: 24,
            ),
          ),
        ],
      ),
    );
  }
}
7
likes
150
points
96
downloads

Publisher

verified publisherapptakk.com

Weekly Downloads

A minimal CSV localization package built on LocalizationsDelegate.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

csv, flutter

More

Packages that depend on csv_localizations