lazy_loc 0.0.6 copy "lazy_loc: ^0.0.6" to clipboard
lazy_loc: ^0.0.6 copied to clipboard

LazyLoc is a lightweight localization package for Flutter that automates translation file management and provides a simple `.tr()` extension for string translation.

example/lib/main.dart

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

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

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'LazyLoc Demo',

      // 1. Register supported locales
      supportedLocales: const [
        Locale('ko'), // Korean
        Locale('en'), // English
      ],

      // 2. Register delegates (this is the connection!)
      localizationsDelegates: const [
        lazyLocDelegate, // Our custom delegate
        // Flutter default widget delegates
        GlobalMaterialLocalizations.delegate,
        GlobalWidgetsLocalizations.delegate,
        GlobalCupertinoLocalizations.delegate,
      ],

      home: const MyHomePage(),
    );
  }
}

class MyHomePage extends StatelessWidget {
  const MyHomePage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('app_title'.tr()),
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Text(
              'hello'.tr(),
              style: Theme.of(context).textTheme.headlineMedium,
            ),
            const SizedBox(height: 16),
            Text('world'.tr(), style: Theme.of(context).textTheme.bodyLarge),
            const SizedBox(height: 16),
            Text(
              'welcome_message'.tr(),
              style: Theme.of(context).textTheme.bodyMedium,
            ),
          ],
        ),
      ),
    );
  }
}
0
likes
160
points
164
downloads
screenshot

Publisher

unverified uploader

Weekly Downloads

LazyLoc is a lightweight localization package for Flutter that automates translation file management and provides a simple `.tr()` extension for string translation.

Homepage
Repository (GitHub)
View/report issues

Topics

#i18n #l10n #localization #translation

Documentation

Documentation
API reference

License

MIT (license)

Dependencies

args, flutter, glob, path, plugin_platform_interface

More

Packages that depend on lazy_loc