translate_hub_handler 1.0.0 copy "translate_hub_handler: ^1.0.0" to clipboard
translate_hub_handler: ^1.0.0 copied to clipboard

Over-The-Air (OTA) localization SDK for Flutter. Update translations instantly without resubmitting to the App Store or Google Play. Supports offline fallback, automatic language resolution, and daily [...]

translate_hub_handler #

pub.dev License: MIT

Over-The-Air (OTA) localization SDK for Flutter. Update your app's translations instantly — no App Store or Google Play resubmission required.

Manage all your translation keys from the TranslationsHub dashboard, and the SDK delivers updates to your users automatically every day.


Features #

  • OTA updates — translations refresh daily in the background
  • Offline fallback — bundled JSON asset used when the network is unavailable
  • Zero backend cost — translations are fetched directly via a signed URL
  • Automatic language resolution — saved choice → device locale → en
  • RTL supportTHLanguageItem.textDirection for Arabic, Hebrew, etc.
  • Simple API — one .translate extension on String

Installation #

dependencies:
  translate_hub_handler: ^1.0.0
flutter pub get

Setup #

1. Add INTERNET permission (Android only) #

Flutter does not include the INTERNET permission by default on Android.

<!-- android/app/src/main/AndroidManifest.xml -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
    <uses-permission android:name="android.permission.INTERNET"/>
    ...
</manifest>

Place your translations.json in assets/ and register it in pubspec.yaml:

flutter:
  assets:
    - assets/translations.json

See the JSON format section below.


Usage #

Initialize #

import 'package:translate_hub_handler/translate_hub_handler.dart';

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await TranslateHub.shared.initialize(
    const TranslateHubConfig(
      apiKey: 'YOUR_API_KEY',        // from the TranslationsHub dashboard
      fallbackFile: 'translations',  // asset name without .json
    ),
  );
  runApp(const MyApp());
}

Translate strings #

// In any widget:
Text('greeting'.translate ?? 'Hello!'),
Text('subtitle'.translate ?? 'Welcome'),

Switch language #

final hub = TranslateHub.shared;

// Available languages
final languages = hub.translation?.languages ?? [];

// Current language
final current = hub.current; // THLanguageItem?

// RTL direction (useful for Directionality widget)
final dir = current?.textDirection; // TextDirection.ltr / .rtl

// Switch
hub.pickLanguage('he');
setState(() {});

Offline mode #

const TranslateHubConfig(
  apiKey: 'YOUR_API_KEY',
  fallbackFile: 'translations',
  offline: true,  // skip network, load bundled asset only
)

JSON Format #

All languages share the same file structure:

{
  "languages": [
    { "code": "en", "name": "English", "direction": "ltr" },
    { "code": "fr", "name": "French",  "direction": "ltr" },
    { "code": "he", "name": "Hebrew",  "direction": "rtl" }
  ],
  "en": {
    "greeting": "Hello!",
    "subtitle": "Your app, in every language"
  },
  "fr": {
    "greeting": "Bonjour!",
    "subtitle": "Votre app, dans toutes les langues"
  },
  "he": {
    "greeting": "שלום!",
    "subtitle": "האפליקציה שלך, בכל שפה"
  }
}

Additional information #

0
likes
130
points
63
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Over-The-Air (OTA) localization SDK for Flutter. Update translations instantly without resubmitting to the App Store or Google Play. Supports offline fallback, automatic language resolution, and daily background refresh.

Topics

#localization #i18n #translation #ota #flutter

License

MIT (license)

Dependencies

flutter, http, shared_preferences

More

Packages that depend on translate_hub_handler