localizely_sdk 2.0.0 copy "localizely_sdk: ^2.0.0" to clipboard
localizely_sdk: ^2.0.0 copied to clipboard

outdated

Localizely SDK for Flutter enables Over-the-air translations update from Localizely cloud platform

Localizely SDK #

pub package

SDK setup #

  1. Update pubspec.yaml file:
dependencies:
  ...
  localizely_sdk: ^2.0.0

flutter_intl:
  ...
  localizely:
    ota_enabled: true # Required for Over-the-air translation updates
  1. Trigger localization files generation by Flutter Intl IDE plugin or by intl_utils library

  2. Initialize Localizely SDK (e.g. main.dart file):

import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:localizely_sdk/localizely_sdk.dart'; // Import sdk package
import 'generated/l10n.dart';

void main() {
  Localizely.init('<SDK_TOKEN>', '<DISTRIBUTION_ID>'); // Init sdk 
  Localizely.setPreRelease(true); // Add this only if you want to use prereleases
  Localizely.setAppVersion('<APP_VERSION>'); // Add this only if you want to explicitly set the application version, or in cases when automatic detection is not possible (e.g. Flutter web apps)

  runApp(MaterialApp(
      onGenerateTitle: (context) => S.of(context).appTitle,
      localizationsDelegates: [
        S.delegate,
        GlobalMaterialLocalizations.delegate,
        GlobalWidgetsLocalizations.delegate,
        GlobalCupertinoLocalizations.delegate,
      ],
      supportedLocales: S.delegate.supportedLocales,
      home: HomePage()));
}

class HomePage extends StatefulWidget {
  @override
  State<StatefulWidget> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  bool _isLoading = true;

  @override
  void initState() {
    super.initState();

    Localizely.updateTranslations().then( // Call 'updateTranslations' after localization delegates initialization
        (response) => setState(() {
              _isLoading = false;
            }),
        onError: (error) => setState(() {
              _isLoading = false;
            }));
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(title: Text(S.of(context).pageHomeTitle)),
        body: Center(
            child: _isLoading ? CircularProgressIndicator() : Column(children: <Widget>[Text(S.of(context).welcome)])));
  }
}

More #

Complete over-the-air documentation: https://localizely.com/flutter-over-the-air/

Sample app with over-the-air translation updates: https://github.com/localizely/flutter-ota-sample-app

20
likes
0
pub points
92%
popularity

Publisher

verified publisherlocalizely.com

Localizely SDK for Flutter enables Over-the-air translations update from Localizely cloud platform

Homepage

License

unknown (LICENSE)

Dependencies

http, intl, logger, package_info, path_provider, petitparser, shared_preferences, uuid

More

Packages that depend on localizely_sdk