Added multilingual support
This commit is contained in:
parent
1f1ef19743
commit
d20b69358f
|
@ -0,0 +1,3 @@
|
|||
arb-dir: lib/l10n
|
||||
template-arb-file: app_en.arb
|
||||
output-localization-file: app_localizations.dart
|
|
@ -0,0 +1,38 @@
|
|||
{
|
||||
"@@locale": "de",
|
||||
"appTitle": "Ollama",
|
||||
"@appTitle": {
|
||||
"description": "Title of the application",
|
||||
"context": "Visible in the side bar"
|
||||
},
|
||||
"optionSettings": "Einstellungen",
|
||||
"@optionSettings": {
|
||||
"description": "Text displayed for settings option",
|
||||
"context": "Visible in the side bar"
|
||||
},
|
||||
"optionNewChat": "Neuer Chat",
|
||||
"@optionNewChat": {
|
||||
"description": "Text displayed for new chat option",
|
||||
"context": "Visible in the side bar"
|
||||
},
|
||||
"noSelectedModel": "<selektor>",
|
||||
"@noSelectedModel": {
|
||||
"description": "Text displayed when no model is selected",
|
||||
"context": "Visible in model selector, above the chat viewF"
|
||||
},
|
||||
"uploadImage": "Bild Hochladen",
|
||||
"@uploadImage": {
|
||||
"description": "Text displayed for image upload button",
|
||||
"context": "Visible in attachment menu"
|
||||
},
|
||||
"uploadFile": "Datei Hochladen",
|
||||
"@uploadFile": {
|
||||
"description": "Text displayed for file upload button",
|
||||
"context": "Visible in attachment menu"
|
||||
},
|
||||
"messageInputPlaceholder": "Nachricht",
|
||||
"@messageInputPlaceholder": {
|
||||
"description": "Placeholder text for message input",
|
||||
"context": "Visible in the chat view"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
{
|
||||
"@@locale": "en",
|
||||
"appTitle": "Ollama",
|
||||
"@appTitle": {
|
||||
"description": "Title of the application",
|
||||
"context": "Visible in the side bar"
|
||||
},
|
||||
"optionSettings": "Settings",
|
||||
"@optionSettings": {
|
||||
"description": "Text displayed for settings option",
|
||||
"context": "Visible in the side bar"
|
||||
},
|
||||
"optionNewChat": "New Chat",
|
||||
"@optionNewChat": {
|
||||
"description": "Text displayed for new chat option",
|
||||
"context": "Visible in the side bar"
|
||||
},
|
||||
"noSelectedModel": "<selector>",
|
||||
"@noSelectedModel": {
|
||||
"description": "Text displayed when no model is selected",
|
||||
"context": "Visible in model selector, above the chat viewF"
|
||||
},
|
||||
"uploadImage": "Upload Image",
|
||||
"@uploadImage": {
|
||||
"description": "Text displayed for image upload button",
|
||||
"context": "Visible in attachment menu"
|
||||
},
|
||||
"uploadFile": "Upload File",
|
||||
"@uploadFile": {
|
||||
"description": "Text displayed for file upload button",
|
||||
"context": "Visible in attachment menu"
|
||||
},
|
||||
"messageInputPlaceholder": "Message",
|
||||
"@messageInputPlaceholder": {
|
||||
"description": "Placeholder text for message input",
|
||||
"context": "Visible in the chat view"
|
||||
}
|
||||
}
|
|
@ -1,6 +1,8 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:flutter_chat_types/flutter_chat_types.dart' as types;
|
||||
import 'package:flutter_chat_ui/flutter_chat_ui.dart';
|
||||
|
@ -97,7 +99,12 @@ class _AppState extends State<App> {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
theme: theme, darkTheme: themeDark, home: const MainApp());
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
supportedLocales: AppLocalizations.supportedLocales,
|
||||
title: "Ollama",
|
||||
theme: theme,
|
||||
darkTheme: themeDark,
|
||||
home: const MainApp());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -141,19 +148,20 @@ class _MainAppState extends State<MainApp> {
|
|||
splashFactory: NoSplash.splashFactory,
|
||||
highlightColor: Colors.transparent,
|
||||
enableFeedback: false,
|
||||
child: const SizedBox(
|
||||
child: SizedBox(
|
||||
height: 72,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
Flexible(
|
||||
child: Text("<none>",
|
||||
child: Text(
|
||||
AppLocalizations.of(context)!.noSelectedModel,
|
||||
overflow: TextOverflow.fade,
|
||||
style: TextStyle(
|
||||
style: const TextStyle(
|
||||
fontFamily: "monospace", fontSize: 16))),
|
||||
SizedBox(width: 4),
|
||||
Icon(Icons.expand_more_rounded)
|
||||
const SizedBox(width: 4),
|
||||
const Icon(Icons.expand_more_rounded)
|
||||
]))),
|
||||
actions: [
|
||||
IconButton(
|
||||
|
@ -245,7 +253,9 @@ class _MainAppState extends State<MainApp> {
|
|||
HapticFeedback.selectionClick();
|
||||
},
|
||||
icon: const Icon(Icons.image_rounded),
|
||||
label: const Text("Upload Image"))),
|
||||
label: Text(
|
||||
AppLocalizations.of(context)!
|
||||
.uploadImage))),
|
||||
const SizedBox(height: 8),
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
|
@ -279,11 +289,15 @@ class _MainAppState extends State<MainApp> {
|
|||
},
|
||||
icon: const Icon(
|
||||
Icons.file_copy_rounded),
|
||||
label: const Text("Upload File")))
|
||||
label: Text(
|
||||
AppLocalizations.of(context)!
|
||||
.uploadFile)))
|
||||
]));
|
||||
});
|
||||
},
|
||||
l10n: const ChatL10nEn(),
|
||||
l10n: ChatL10nEn(
|
||||
inputPlaceholder:
|
||||
AppLocalizations.of(context)!.messageInputPlaceholder),
|
||||
inputOptions: const InputOptions(
|
||||
keyboardType: TextInputType.text,
|
||||
sendButtonVisibilityMode: SendButtonVisibilityMode.always),
|
||||
|
@ -315,8 +329,7 @@ class _MainAppState extends State<MainApp> {
|
|||
? 0
|
||||
: 8))
|
||||
: DarkChatTheme(
|
||||
backgroundColor:
|
||||
(themeDark ?? ThemeData.dark()).colorScheme.background,
|
||||
backgroundColor: (themeDark ?? ThemeData.dark()).colorScheme.background,
|
||||
primaryColor: (themeDark ?? ThemeData.dark()).colorScheme.primary.withAlpha(40),
|
||||
attachmentButtonIcon: const Icon(Icons.file_upload_rounded),
|
||||
sendButtonIcon: const Icon(Icons.send_rounded),
|
||||
|
@ -341,16 +354,18 @@ class _MainAppState extends State<MainApp> {
|
|||
}
|
||||
},
|
||||
selectedIndex: 1,
|
||||
children: const [
|
||||
children: [
|
||||
NavigationDrawerDestination(
|
||||
icon: ImageIcon(AssetImage("assets/logo512.png")),
|
||||
label: Text("Ollama"),
|
||||
icon: const ImageIcon(AssetImage("assets/logo512.png")),
|
||||
label: Text(AppLocalizations.of(context)!.appTitle),
|
||||
),
|
||||
Divider(),
|
||||
const Divider(),
|
||||
NavigationDrawerDestination(
|
||||
icon: Icon(Icons.add_rounded), label: Text("New Chat")),
|
||||
icon: const Icon(Icons.add_rounded),
|
||||
label: Text(AppLocalizations.of(context)!.optionNewChat)),
|
||||
NavigationDrawerDestination(
|
||||
icon: Icon(Icons.settings_rounded), label: Text("Settings"))
|
||||
icon: const Icon(Icons.settings_rounded),
|
||||
label: Text(AppLocalizations.of(context)!.optionSettings))
|
||||
]));
|
||||
}
|
||||
}
|
||||
|
|
11
pubspec.lock
11
pubspec.lock
|
@ -206,6 +206,11 @@ packages:
|
|||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.0.2"
|
||||
flutter_localizations:
|
||||
dependency: "direct main"
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
flutter_parsed_text:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -321,13 +326,13 @@ packages:
|
|||
source: hosted
|
||||
version: "0.2.1+1"
|
||||
intl:
|
||||
dependency: transitive
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: intl
|
||||
sha256: d6f56758b7d3014a48af9701c085700aac781a92a87a62b1333b46d8879661cf
|
||||
sha256: "3bc132a9dbce73a7e4a21a17d06e1878839ffbf975568bc875c60537824b0c4d"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.19.0"
|
||||
version: "0.18.1"
|
||||
json_annotation:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
|
@ -16,6 +16,9 @@ dependencies:
|
|||
image_picker: ^1.1.1
|
||||
file_picker: ^8.0.3
|
||||
visibility_detector: ^0.4.0+2
|
||||
flutter_localizations:
|
||||
sdk: flutter
|
||||
intl: any
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
|
@ -24,5 +27,6 @@ dev_dependencies:
|
|||
|
||||
flutter:
|
||||
uses-material-design: true
|
||||
generate: true
|
||||
assets:
|
||||
- assets/logo512.png
|
||||
|
|
Loading…
Reference in New Issue