https://github.com/phrase/phrase-flutter-sdk
Phrase Flutter SDK
https://github.com/phrase/phrase-flutter-sdk
Last synced: 5 months ago
JSON representation
Phrase Flutter SDK
- Host: GitHub
- URL: https://github.com/phrase/phrase-flutter-sdk
- Owner: phrase
- License: other
- Created: 2022-02-25T10:21:08.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2025-07-21T09:34:49.000Z (12 months ago)
- Last Synced: 2025-09-05T19:13:56.010Z (10 months ago)
- Size: 6.84 KB
- Stars: 0
- Watchers: 13
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
- Notice: NOTICE.txt
Awesome Lists containing this project
README
# Phrase Over the Air SDK for Flutter
Publish your translations faster and simpler than ever before. Stop waiting for the next deployment and start publishing all your translations in real-time directly in Phrase.
Head over to the Phrase Help Center to learn about this feature and how to use it in your apps: https://support.phrase.com/hc/en-us/articles/5804059067804
## Instructions
With the SDK, the app regularly checks for updated translations and downloads them in the background.
Example [app](https://github.com/phrase/flutter_sdk_example)
### Requirements
This library depends on 0.18.0 or greater of Flutter's [intl](https://pub.dev/packages/intl) library. Follow [their guide](https://docs.flutter.dev/ui/accessibility-and-internationalization/internationalization) to add localizations support to the app.
### Installation
Add Phrase to the pubspec.yaml:
```yaml
dependencies:
phrase: ^2.5.2
...
intl: ^0.19.0
flutter_localizations:
sdk: flutter
...
flutter:
generate: true
...
```
Like in the `intl` library, code generation is used to process ARB files. Run this command to update:
```
flutter pub run phrase
```
Using build_runner:
```
flutter pub run build_runner watch
```
### Usage
Initialize Phrase in the `main.dart` file:
```dart
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:flutter_gen/gen_l10n/phrase_localizations.dart';
import 'package:phrase/phrase.dart';
void main() {
Phrase.setup("[DISTRIBUTION_ID]", "[ENVIRONMENT_ID]");
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
//..
localizationsDelegates: PhraseLocalizations.localizationsDelegates,
supportedLocales: PhraseLocalizations.supportedLocales,
);
}
}
```
Access messages with:
```dart
Text(AppLocalizations.of(context)!.helloWorld);
```
### Update behavior
OTA translations are updated every time the app launches. To disable this:
```dart
Phrase.setup("[DISTRIBUTION_ID]", "[ENVIRONMENT_ID]", checkForUpdates: false);
```
To update manually:
```dart
Phrase.updateTranslations(context).then((_) => print("Done!"));
```
### Custom app version
The SDK uses the app version by default to return a release which matches the release constraints for the min and max version. The app version must use semantic versioning otherwise no translation update will be returned. In case app does not use semantic versioning, the app version can be manually overridden: it is possible to manually override the app version:
```dart
Phrase.setup("[DISTRIBUTION_ID]", "[ENVIRONMENT_ID]", customAppVersion: "1.2.3");
```
### Configure US data center
Phrase US data center is also supported. The US data center can be selected by passing the relevant API hostname parameter in the SDK configuration:
```dart
Phrase.setup("[DISTRIBUTION_ID]", "[ENVIRONMENT_ID]", host: PhraseHost.us);
```