localizely_sdk 1.2.2

Flutter Android iOS

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: ^1.2.2

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)])));
  }
}
4
likes
90
pub points
76%
popularity

Publisher

localizely.com

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

Homepage

Documentation

API reference

License

BSD (LICENSE)

Dependencies

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

More

Packages that depend on localizely_sdk