locale_sync 1.0.1 copy "locale_sync: ^1.0.1" to clipboard
locale_sync: ^1.0.1 copied to clipboard

An easy-to-use internationalization package for Flutter

Locale Sync - Flutter #

This package is a helper for Locale Sync Service . Since most code is generated, you'll be able to edit those files to increment it with your own implementations, if want to.

The API itself is RESTful and can be accessed with your account credentials without any need of a SDK.

Installation #

flutter pub add locale_sync

How to use it #

Place your translation_fallback.json file you've downloaded from the editor in a lib/translations folder then run the following command:

Generating files #

dart run locale_sync gen

Setting up #

Once generated files, you'll be able to see then in lib/translations.

  1. Call setup method on your main method, with your credentials:
void main() async {
  await LocaleSync.setup(
    apiToken: "e7b52dfd-57bd-4bc6-9738-cad3be7cfd9d",
    repositoryId: "repository:s6udatrquzh2c5m0ye8c",
  );
  /* Start your app */
  runApp(const MyApp());
}
  1. Add localization setup to app widget
import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'translations/locale_sync.dart';

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      locale: const Locale("pt"),
      /* Add your supported languages according to dashboard */
      supportedLocales: const [
        Locale("en"),
        Locale("en", "US"),
        Locale("en", "CA"),
        Locale("pt"),
        Locale("pt", "BR"),
      ],
      localizationsDelegates: [
        /*Add this*/
        LocaleSync.delegate,
        GlobalCupertinoLocalizations.delegate,
        GlobalMaterialLocalizations.delegate,
        GlobalWidgetsLocalizations.delegate,
      ],
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

Translating #

print(LocaleSync.of(context).string_edit);
print(LocaleSync.of(context).notifications(2));

See docs #

You can check our docs for more detailed examples and in-depth understanding

0
likes
0
pub points
0%
popularity

Publisher

unverified uploader

An easy-to-use internationalization package for Flutter

License

unknown (license)

Dependencies

dio, flutter, flutter_localizations, hive, hive_flutter, intl, path

More

Packages that depend on locale_sync