language_improver 0.0.1
language_improver: ^0.0.1 copied to clipboard
A Flutter package to enhance, edit, and manage translation strings and conditions for multi-language apps.
language_improver #
A Flutter package that provides a beautiful and intuitive widget for improving translations side-by-side with a reference language. Built on top of the language_helper package.
Features #
- 📝 Side-by-side comparison: View default (reference) and target translations together for easy improvement
- 🔍 Search & filter: Quickly find translations by key or content
- ✏️ Edit translations: Inline editing with text fields for each translation
- 📍 Scroll to key: Automatically scroll to and highlight specific translation keys
- ✨ Flash animation: Visual highlighting with smooth flash animations when scrolling to keys
- 🌐 Multi-language support: Works with all languages supported by
language_helper - 🔢 LanguageConditions support: Edit and manage plural forms with
LanguageConditions - 💾 Save & cancel: Callbacks for handling updated translations and cancellation
- 🎨 Customizable: Show/hide translation keys, configure default and target languages
Getting started #
Prerequisites #
This package depends on language_helper package. Make sure you have it set up in your project.
Installation #
Add this to your package's pubspec.yaml file:
dependencies:
language_improver: ^0.0.1
language_helper: ^0.13.0-rc.4
Then run:
flutter pub get
Usage #
Basic Example #
import 'package:flutter/material.dart';
import 'package:language_helper/language_helper.dart';
import 'package:language_improver/language_improver.dart';
class TranslationEditor extends StatelessWidget {
@override
Widget build(BuildContext context) {
return LanguageImprover(
languageHelper: LanguageHelper.instance,
onTranslationsUpdated: (updatedTranslations) {
// Handle the improved translations
print('Updated translations: $updatedTranslations');
// You can save these to your storage or update your language files
},
onCancel: () {
// Handle cancellation if needed
print('Translation editing cancelled');
},
);
}
}
Navigate to Translation Editor #
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => LanguageImprover(
languageHelper: LanguageHelper.instance,
onTranslationsUpdated: (translations) async {
// Save translations to your storage
await saveTranslations(translations);
},
),
),
);
With Initial Configuration #
LanguageImprover(
languageHelper: LanguageHelper.instance,
initialDefaultLanguage: LanguageCodes.en,
initialTargetLanguage: LanguageCodes.vi,
scrollToKey: 'welcome_message',
autoSearchOnScroll: true,
showKey: true,
onTranslationsUpdated: (translations) {
// Process updated translations
},
)
Scroll to Specific Key #
LanguageImprover(
languageHelper: LanguageHelper.instance,
scrollToKey: 'hello_world', // Automatically scrolls to this key
autoSearchOnScroll: true, // Also searches for this key
onTranslationsUpdated: (translations) {
// Handle updates
},
)
API Reference #
LanguageImprover Widget #
| Parameter | Type | Description |
|---|---|---|
languageHelper |
LanguageHelper? |
The LanguageHelper instance to use. If not provided, uses LanguageHelper.instance. |
onTranslationsUpdated |
FutureOr<void> Function(Map<LanguageCodes, Map<String, dynamic>>)? |
Callback called when translations are saved. Receives updated translations map. Can be async. |
onCancel |
VoidCallback? |
Callback called when the user cancels editing. |
initialDefaultLanguage |
LanguageCodes? |
Initial default/reference language. If not provided, uses first available language. |
initialTargetLanguage |
LanguageCodes? |
Initial target language to improve. If not provided, uses current language. |
scrollToKey |
String? |
Initial key to scroll to and focus on. Widget will automatically scroll to this key. |
autoSearchOnScroll |
bool |
Whether to automatically search for scrollToKey when provided. Defaults to true. |
showKey |
bool |
Whether to show translation keys. If false, only shows default and target translations. Defaults to true. |
Features in Detail #
Translation Editing #
The widget displays translations in a list format with:
- Default/reference language on the left
- Target language (editable) on the right
- Optional translation key display
- Support for both
StringandLanguageConditionstypes
Search Functionality #
Search filters translations by:
- Translation keys
- Translation content (both default and target languages)
Scroll to Key #
When scrollToKey is provided:
- Automatically scrolls to the specified key
- Optionally searches for the key (if
autoSearchOnScrollis true) - Flashes the key with an animation to draw attention
LanguageConditions Support #
The widget fully supports LanguageConditions for handling plural forms:
- Displays condition information
- Allows editing of condition values
- Properly handles condition comparisons when saving
Additional Information #
Requirements #
- Flutter SDK:
>=3.35.0 - Dart SDK:
^3.9.0 language_helper:^0.13.0-rc.4
Package Information #
- Version: 0.0.1
- Homepage: https://github.com/lamnhan066/language_improver
Contributing #
Contributions are welcome! Please feel free to submit a Pull Request.
License #
See the LICENSE file for details.