Fix Scribe translations by using multiple_localization package
Even if all keys were translated, Scribe UI was always in default language. In short, it is not possible to load multiple localization delegates with different .arb files. But we need these translations to be located in a separate file because in the future we will move Scribe in a separate module. See https://github.com/Innim/flutter_multiple_localization for more explanation.
This commit is contained in:
@@ -1534,6 +1534,14 @@ packages:
|
||||
relative: true
|
||||
source: path
|
||||
version: "1.0.0+1"
|
||||
multiple_localization:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: multiple_localization
|
||||
sha256: "29c97a3fbf4d067ea5a63df1995465ea81ef28e2c817d9d0871983e50f4fd3f0"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.6.0"
|
||||
nm:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:multiple_localization/multiple_localization.dart';
|
||||
import 'package:scribe/scribe/ai/l10n/messages_all.dart';
|
||||
|
||||
class ScribeLocalizations {
|
||||
@@ -7,16 +8,13 @@ class ScribeLocalizations {
|
||||
return Localizations.of<ScribeLocalizations>(context, ScribeLocalizations)!;
|
||||
}
|
||||
|
||||
static Future<ScribeLocalizations> load(Locale locale) async {
|
||||
final name =
|
||||
locale.countryCode == null ? locale.languageCode : locale.toString();
|
||||
|
||||
final localeName = Intl.canonicalizedLocale(name);
|
||||
|
||||
return initializeMessages(localeName).then((_) {
|
||||
Intl.defaultLocale = localeName;
|
||||
return ScribeLocalizations();
|
||||
});
|
||||
static Future<ScribeLocalizations> load(Locale locale) {
|
||||
return MultipleLocalizations.load(
|
||||
initializeMessages,
|
||||
locale,
|
||||
(locale) => ScribeLocalizations(),
|
||||
setDefaultLocale: true,
|
||||
);
|
||||
}
|
||||
|
||||
static const LocalizationsDelegate<ScribeLocalizations> delegate =
|
||||
|
||||
@@ -798,6 +798,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.6"
|
||||
multiple_localization:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: multiple_localization
|
||||
sha256: "29c97a3fbf4d067ea5a63df1995465ea81ef28e2c817d9d0871983e50f4fd3f0"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.6.0"
|
||||
objective_c:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
||||
@@ -38,6 +38,8 @@ dependencies:
|
||||
|
||||
flutter_svg: 2.1.0
|
||||
|
||||
multiple_localization: 0.6.0
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
|
||||
Reference in New Issue
Block a user