weblate_sdk 0.1.1 copy "weblate_sdk: ^0.1.1" to clipboard
weblate_sdk: ^0.1.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
  );

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
0
pub points
53%
popularity

Publisher

unverified uploader

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

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

dio, flutter, flutter_web_plugins, hive, hive_flutter, plugin_platform_interface, shared_preferences

More

Packages that depend on weblate_sdk