weblate_sdk 0.2.1 copy "weblate_sdk: ^0.2.1" to clipboard
weblate_sdk: ^0.2.1 copied to clipboard

Unofficial WebLate SDK. Designed to work with WebLate web-based continuous localization system.

weblate_sdk #

Unofficial SDK to use Weblate service for a Web-based continuous localization;

Check Weblate documentation for more details.

Getting Started #

Add package and localization support to your pubspec.yaml:

weblate_sdk: latest
flutter_localizations:
    sdk: flutter

Add initialization to your main function:

 await WebLateSdk.initialize(
    token: 'your token',
    host: 'your host',
    projectName: 'name of project',
    componentName: 'name of component',
    defaultLanguage: 'en',
    disableCache: false, //optional
    cacheLive: const Duration(days: 1), //optional
    fallbackJson: 'assets/default.json', //optional
  );

Android Setup

Increase minSdk version in build.gradle to 19 at least.

defaultConfig {
        minSdkVersion 19
    } 

Parameters description:

token - your project token. You can create project in WebLate project API access settings and set at least Languages permission for token;

host - your WebLate host url;

Note: host should be with https:// (for example: https://weblate.company.link

projectName - your WebLate project name;

componentName - your project component name;

defaultLanguage - default language to use if key for current language not found.

If translation not found for current language then translation for defaultLanguage will be used instead

disableCache - disable or enable caching. By default cache disabled on debug and enabled on release;

cacheLive - cache live time. By default 2 hours;

fallbackTranslations - fallback translations file. This used in case when SDK not initialized properly or when user runs app without internet connection and cached translations;

Add localization to MaterialApp:

supportedLocales: WebLateSdk.supportedLocales,
localizationsDelegates: [
        GlobalMaterialLocalizations.delegate,
        GlobalWidgetsLocalizations.delegate,
        GlobalCupertinoLocalizations.delegate,
        WebLateSdk.delegate,
      ]

Use localized strings in your code:

context.localizedValueOf('key');

Optionally you can use translations formatting:

context.localizedValueOf('key', format: ['John Doe', ...]);

Note: To use formatting parts to replace should be highlighted with { and }. For example: 'Welcome {username}!'

Note: Do not forgot to add internet permissions for you platforms

##Web support

Please read about CORS and make sure that CORS setup properly.

##Hae a suggestion or found a bug?

Have a suggestion or found a bug? Please let us know HERE.

11
likes
150
points
103
downloads

Publisher

unverified uploader

Weekly Downloads

Unofficial WebLate SDK. Designed to work with WebLate web-based continuous localization system.

Repository (GitHub)
View/report issues

Documentation

API reference

License

Apache-2.0 (license)

Dependencies

connectivity_plus, dio, flutter, flutter_web_plugins, internet_connection_checker_plus, json_annotation, json_serializable, plugin_platform_interface, shared_preferences

More

Packages that depend on weblate_sdk