mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-29 10:17:16 +08:00
Make some strings translatable
Instead of hard-coding the strings.
This commit is contained in:
@ -36,3 +36,29 @@ actions:
|
||||
newNote: New Note
|
||||
newJournal: New Journal Entry
|
||||
newChecklist: New Checklist
|
||||
screens:
|
||||
folders:
|
||||
title: Folders
|
||||
selected: Folder Selected
|
||||
dialog:
|
||||
title: Create new Folder
|
||||
create: Create
|
||||
discard: Discard
|
||||
errorDialog:
|
||||
title: Error
|
||||
content: Cannot delete a Folder which contains notes
|
||||
ok: Ok
|
||||
actions:
|
||||
rename: Rename Folder
|
||||
subFolder: Create Sub-Folder
|
||||
delete: Delete Folder
|
||||
decoration: Folder Name
|
||||
empty: Please enter a name
|
||||
widgets:
|
||||
rename:
|
||||
yes: Rename
|
||||
no: Cancel
|
||||
validator:
|
||||
empty: Please enter a name
|
||||
exists: Already Exists
|
||||
contains: Cannot contain /
|
||||
|
@ -1,3 +1,4 @@
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
@ -51,16 +52,16 @@ class _FolderListingScreenState extends State<FolderListingScreen> {
|
||||
action = PopupMenuButton(
|
||||
itemBuilder: (context) {
|
||||
return [
|
||||
const PopupMenuItem<String>(
|
||||
child: Text("Rename Folder"),
|
||||
PopupMenuItem<String>(
|
||||
child: Text(tr("screens.folders.actions.rename")),
|
||||
value: "Rename",
|
||||
),
|
||||
const PopupMenuItem<String>(
|
||||
child: Text("Create Sub-Folder"),
|
||||
PopupMenuItem<String>(
|
||||
child: Text(tr("screens.folders.actions.subFolder")),
|
||||
value: "Create",
|
||||
),
|
||||
const PopupMenuItem<String>(
|
||||
child: Text("Delete Folder"),
|
||||
PopupMenuItem<String>(
|
||||
child: Text(tr("screens.folders.actions.delete")),
|
||||
value: "Delete",
|
||||
),
|
||||
];
|
||||
@ -71,8 +72,8 @@ class _FolderListingScreenState extends State<FolderListingScreen> {
|
||||
context: context,
|
||||
builder: (_) => RenameDialog(
|
||||
oldPath: selectedFolder.folderPath,
|
||||
inputDecoration: 'Folder Name',
|
||||
dialogTitle: "Rename Folder",
|
||||
inputDecoration: tr("screens.folders.actions.decoration"),
|
||||
dialogTitle: tr("screens.folders.actions.rename"),
|
||||
),
|
||||
);
|
||||
if (folderName is String) {
|
||||
@ -115,9 +116,9 @@ class _FolderListingScreenState extends State<FolderListingScreen> {
|
||||
},
|
||||
);
|
||||
|
||||
var title = const Text("Folders");
|
||||
var title = Text(tr('screens.folders.title'));
|
||||
if (selectedFolder != null) {
|
||||
title = const Text("Folder Selected");
|
||||
title = Text(tr("screens.folders.selected"));
|
||||
}
|
||||
|
||||
return Scaffold(
|
||||
@ -173,9 +174,11 @@ class _CreateFolderAlertDialogState extends State<CreateFolderAlertDialog> {
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
TextFormField(
|
||||
decoration: const InputDecoration(labelText: 'Folder Name'),
|
||||
decoration: InputDecoration(
|
||||
labelText: tr("screens.folders.actions.decoration"),
|
||||
),
|
||||
validator: (value) {
|
||||
if (value.isEmpty) return 'Please enter a name';
|
||||
if (value.isEmpty) return tr("screens.folders.actions.empty");
|
||||
return "";
|
||||
},
|
||||
autofocus: true,
|
||||
@ -188,18 +191,18 @@ class _CreateFolderAlertDialogState extends State<CreateFolderAlertDialog> {
|
||||
);
|
||||
|
||||
return AlertDialog(
|
||||
title: const Text("Create new Folder"),
|
||||
title: Text(tr("screens.folders.dialog.title")),
|
||||
actions: <Widget>[
|
||||
FlatButton(
|
||||
onPressed: () => Navigator.of(context).pop(false),
|
||||
child: const Text("Discard"),
|
||||
child: Text(tr("screens.folders.dialog.create")),
|
||||
),
|
||||
FlatButton(
|
||||
onPressed: () {
|
||||
var newFolderName = _textController.text;
|
||||
return Navigator.of(context).pop(newFolderName);
|
||||
},
|
||||
child: const Text("Create"),
|
||||
child: Text(tr("screens.folders.dialog.discard")),
|
||||
),
|
||||
],
|
||||
content: form,
|
||||
@ -217,11 +220,11 @@ class FolderErrorDialog extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: const Text("Error"),
|
||||
content: const Text("Cannot delete a Folder which contains notes"),
|
||||
title: Text(tr("screens.folders.errorDialog.title")),
|
||||
content: Text(tr("screens.folders.errorDialog.content")),
|
||||
actions: <Widget>[
|
||||
FlatButton(
|
||||
child: const Text("Ok"),
|
||||
child: Text(tr("screens.folders.errorDialog.ok")),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
],
|
||||
|
@ -1,5 +1,6 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:path/path.dart';
|
||||
import 'package:path/path.dart' as p;
|
||||
@ -40,17 +41,17 @@ class _RenameDialogState extends State<RenameDialog> {
|
||||
decoration: InputDecoration(labelText: widget.inputDecoration),
|
||||
validator: (value) {
|
||||
if (value.isEmpty) {
|
||||
return 'Please enter a name';
|
||||
return tr('widgets.rename.validator.empty');
|
||||
}
|
||||
|
||||
if (value.contains(p.separator)) {
|
||||
return 'Cannot contain ${p.separator}';
|
||||
return tr('widgets.rename.validator.contains');
|
||||
}
|
||||
|
||||
var newPath = join(dirname(widget.oldPath), value);
|
||||
if (FileSystemEntity.typeSync(newPath) !=
|
||||
FileSystemEntityType.notFound) {
|
||||
return 'Already Exists';
|
||||
return tr('widgets.rename.validator.exists');
|
||||
}
|
||||
return null;
|
||||
},
|
||||
@ -68,7 +69,7 @@ class _RenameDialogState extends State<RenameDialog> {
|
||||
actions: <Widget>[
|
||||
FlatButton(
|
||||
onPressed: () => Navigator.of(context).pop(false),
|
||||
child: const Text("Cancel"),
|
||||
child: Text(tr('widgets.rename.no')),
|
||||
),
|
||||
FlatButton(
|
||||
onPressed: () {
|
||||
@ -77,7 +78,7 @@ class _RenameDialogState extends State<RenameDialog> {
|
||||
Navigator.of(context).pop(newName);
|
||||
}
|
||||
},
|
||||
child: const Text("Rename"),
|
||||
child: Text(tr('widgets.rename.yes')),
|
||||
),
|
||||
],
|
||||
content: form,
|
||||
|
Reference in New Issue
Block a user