localingo 1.0.2 copy "localingo: ^1.0.2" to clipboard
localingo: ^1.0.2 copied to clipboard

Automatic localization package for Flutter with CLI tool for generating translations using Free Translate API. Features type-safe keys, runtime locale switching, and beautiful terminal UI.

๐ŸŒ Localingo ๐ŸŒ

From Egypt to the World

๐ŸŒ Supported Languages #

Localingo supports 13+ languages for its first release:

Language Native Name Code
๐Ÿ‡ธ๐Ÿ‡ฆ Arabic ุงู„ุนุฑุจูŠุฉ ar
๐Ÿ‡ฉ๐Ÿ‡ช German Deutsch de
๐Ÿ‡ซ๐Ÿ‡ท French Franรงais fr
๐Ÿ‡ช๐Ÿ‡ธ Spanish Espaรฑol es
๐Ÿ‡ฎ๐Ÿ‡น Italian Italiano it
๐Ÿ‡ต๐Ÿ‡น Portuguese Portuguรชs pt
๐Ÿ‡ท๐Ÿ‡บ Russian ะ ัƒััะบะธะน ru
๐Ÿ‡ฏ๐Ÿ‡ต Japanese ๆ—ฅๆœฌ่ชž ja
๐Ÿ‡ฐ๐Ÿ‡ท Korean ํ•œ๊ตญ์–ด ko
๐Ÿ‡จ๐Ÿ‡ณ Chinese (Simplified) ็ฎ€ไฝ“ไธญๆ–‡ zh-CN
๐Ÿ‡น๐Ÿ‡ผ Chinese (Traditional) ็น้ซ”ไธญๆ–‡ zh-TW
๐Ÿ‡ฎ๐Ÿ‡ณ Hindi เคนเคฟเคจเฅเคฆเฅ€ hi
๐Ÿ‡น๐Ÿ‡ท Turkish Tรผrkรงe tr
๐Ÿ‡ณ๐Ÿ‡ฑ Dutch Nederlands nl
๐Ÿ‡ต๐Ÿ‡ฑ Polish Polski pl

And many more to be added soon

๐Ÿ“ฆ Installation #

Add Localingo to your pubspec.yaml:

dependencies:
  Localingo: ^1.1.0
  flutter_localizations:
    sdk: flutter

Install dependencies:

flutter pub get

๐Ÿš€ Quick Start (3 Steps) #

Step 1: Create English Translations #

Create assets/l10n/en.json with your app's text:

{
  "app_name": "My Awesome App",
  "welcome": "Welcome!",
  "greeting": "Hello, {name}!",
  "items_count": "{count} items found",
  "login_button": "Login",
  "logout": "Logout"
}

Add to pubspec.yaml:

flutter:
  assets:
    - assets/l10n/

Step 2: Generate Translations #

Run the interactive CLI:

dart run localingo:generate

What happens?

  1. โœ… Reads your en.json file
  2. ๐ŸŽฏ Interactive language selection
  3. ๐ŸŒ Generates translations (e.g., ar.json, fr.json, es.json)
  4. ๐Ÿ”‘ Creates lib/locale_keys.dart with type-safe keys

That's it! ๐ŸŽ‰

Step 3: Use in Your App #

Setup MaterialApp:

import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:Localingo/Localingo.dart';
import 'locale_keys.dart'; // Auto-generated!

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

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

  @override
  Widget build(BuildContext context) {
    // 1. Create a global navigator key
    final navigatorKey = GlobalKey<NavigatorState>();
    
    // 2. Register it with Localingo
    Localingo.setNavigatorKey(navigatorKey);

    return MaterialApp(
      title: 'Localingo Demo',
      
      // 3. Pass it to MaterialApp
      navigatorKey: navigatorKey,
      
      // Add localization delegates
      localizationsDelegates: const [
        AppLocalizations.delegate,
        GlobalMaterialLocalizations.delegate,
        GlobalWidgetsLocalizations.delegate,
        GlobalCupertinoLocalizations.delegate,
      ],
      
      // Specify supported locales
      supportedLocales: const [
        Locale('en'), // English
        Locale('ar'), // Arabic
        Locale('fr'), // French
        Locale('es'), // Spanish
        Locale('de'), // German
      ],
      
      home: const HomePage(),
    );
  }
}

Use Type-Safe Keys (No Context Needed!):

import 'package:Localingo/Localingo.dart';
import 'locale_keys.dart'; // Auto-generated!

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(LocaleKeys.appName), // Simple!
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Text(LocaleKeys.welcome),
            Text(LocaleKeys.greeting),
            ElevatedButton(
              onPressed: () {},
              child: Text(LocaleKeys.loginButton),
            ),
          ],
        ),
      ),
    );
  }
}

Placeholders & Dynamic Text #

Your en.json:

{
  "greeting": "Hello, {name}!",
  "items_count": "{count} items in cart"
}

Usage:

// With LocaleKeys (type-safe)
Text(LocaleKeys.greeting.replaceAll('{name}', 'John'))
Text(LocaleKeys.itemsCount.replaceAll('{count}', '5'))

// Or using the old way with string keys
Text('greeting'.tr().replaceAll('{name}', 'John'))

๐Ÿ“– API Reference #

LocaleKeys (Auto-Generated) #

Type-safe constants generated from your en.json:

class LocaleKeys {
  static String get appName => 'app_name'.tr();
  static String get welcome => 'welcome'.tr();
  static String get greeting => 'greeting'.tr();
  // ... all your keys
}

Usage:

// Use directly (recommended)
Text(LocaleKeys.appName)

// Or use string keys directly
Text('app_name'.tr())

๐Ÿ”ง Troubleshooting #

Q: Translation failed with timeout error?

  • A: The free API may be rate-limited. Wait a moment and try again. The package has automatic retry logic.

Q: Some translations look wrong?

  • A: Auto-translation is good but not perfect. Review and edit generated JSON files manually for production apps.

Q: Can I edit generated translations?

  • A: Yes! Edit the generated ar.json, fr.json, etc. files directly. Re-running the CLI won't overwrite them unless you delete them first.

Q: Do I need an API key?

  • A: No! Localingo is 100% free with no API keys required.

๐Ÿค Contributing #

We welcome contributions from developers around the world! ๐ŸŒ

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

๐Ÿ“ž Support & Community #

  • ๐Ÿ’ผ LinkedIn โ€“ Connect with the creator
  • โ–ถ๏ธ YouTube โ€“ Developer Youtube Channel

โญ Support Localingo #

Enjoying Localingo?
Click the link below and tap the ๐Ÿ‘ LIKE button on pub.dev โ€” it really helps!

๐Ÿ‘‰ https://pub.dev/packages/Localingo


Made with โค๏ธ in Egypt ๐Ÿ‡ช๐Ÿ‡ฌ | Spreading across the world ๐ŸŒ

Breaking language barriers, one app at a time

โฌ† Back to Top

19
likes
130
points
82
downloads

Publisher

unverified uploader

Weekly Downloads

Automatic localization package for Flutter with CLI tool for generating translations using Free Translate API. Features type-safe keys, runtime locale switching, and beautiful terminal UI.

Documentation

API reference

License

unknown (license)

Dependencies

flutter, flutter_localizations

More

Packages that depend on localingo