translations_center 0.1.0 copy "translations_center: ^0.1.0" to clipboard
translations_center: ^0.1.0 copied to clipboard

Offline-first OTA localization SDK for Flutter apps. Stale-While-Revalidate caching with ETag support.

translations_center #

pub package license

Offline-first OTA (Over-The-Air) localization SDK for Flutter apps, featuring Stale-While-Revalidate caching with ETag support.

Architecture #

This package implements an offline-first strategy:

  1. Try loading from SharedPreferences cache (zero latency).
  2. If empty, load from fallback assets.
  3. In the background, ping the server using the stored ETag.
  4. If a newer translation bundle is available (HTTP 200), update the cache.
  5. If nothing changed, the server returns HTTP 304, saving bandwidth.

Missing keys are buffered and automatically reported to the server.

Installation #

dependencies:
  translations_center: ^0.1.0

Quick Start #

1. Initialization #

Call init in your main() before runApp.

import 'package:flutter/material.dart';
import 'package:translations_center/translations_center.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  
  await TranslationsCenter.init(
    serverUrl: 'https://api.translations-center.com',
    apiKey: 'your_api_key_here',
    defaultLocale: const Locale('en'),
    fallbackAssetsPath: 'assets/i18n',
  );
  
  runApp(const MyApp());
}

2. AppStrings Pattern #

Create an enum for your keys:

enum AppStrings {
  exit,
  welcome;
  
  String get([dynamic arg0, dynamic arg1, dynamic arg2, dynamic arg3]) {
    final args = <dynamic>[
      if (arg0 != null) arg0,
      if (arg1 != null) arg1,
      if (arg2 != null) arg2,
      if (arg3 != null) arg3,
    ];
    return TranslationsCenter.instance.get(name, args);
  }
}

3. Usage #

Text(AppStrings.exit.get());
Text(AppStrings.welcome.get('Eyal', 'My App'));

License #

MIT

0
likes
140
points
88
downloads

Documentation

API reference

Publisher

verified publisher3p-cups.com

Weekly Downloads

Offline-first OTA localization SDK for Flutter apps. Stale-While-Revalidate caching with ETag support.

License

MIT (license)

Dependencies

flutter, http, path_provider, shared_preferences

More

Packages that depend on translations_center