From a05e9d04de9aa0a6f477608d22b5791fd8690398 Mon Sep 17 00:00:00 2001 From: Vishesh Handa Date: Thu, 3 Sep 2020 22:21:01 +0200 Subject: [PATCH] Setup: Make more strings translatable --- assets/langs/en.yaml | 18 +++++++++++++++++- lib/setup/clone_url.dart | 19 ++++++++++--------- lib/setup/error.dart | 4 +++- lib/setup/key_editors.dart | 8 +++++--- lib/setup/repo_selector.dart | 2 +- 5 files changed, 36 insertions(+), 15 deletions(-) diff --git a/assets/langs/en.yaml b/assets/langs/en.yaml index af45dc00..935c7f6b 100644 --- a/assets/langs/en.yaml +++ b/assets/langs/en.yaml @@ -206,8 +206,24 @@ setup: repoSelector: title: Select or Create a Repository hint: Type to Search or Create a Repo - next: Next create: Create Repo {} + cloneUrl: + enter: Enter the Git Clone URL + validator: + empty: Please enter some text + invalid: Invalid Input + onlySsh: Only SSH urls are currently accepted + manual: + title: Please create a new git repository - + step1: 1. Go to the website, create a repo and copy its git clone URL + step2: 2. Enter the Git clone URL + button: Open Create New Repo Webpage + next: Next + fail: Failed + keyEditors: + public: Invalid Public Key - Doesn't start with ssh-rsa + private: Invalid Private Key + feature: darkMode: Dark Mode diff --git a/lib/setup/clone_url.dart b/lib/setup/clone_url.dart index 30b31b38..a1b54521 100644 --- a/lib/setup/clone_url.dart +++ b/lib/setup/clone_url.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:easy_localization/easy_localization.dart'; import 'package:function_types/function_types.dart'; import 'package:git_url_parse2/git_url_parse2.dart'; @@ -66,7 +67,7 @@ class GitCloneUrlPageState extends State { Padding( padding: const EdgeInsets.all(8.0), child: Text( - "Enter the Git Clone URL", + tr("setup.cloneUrl.enter"), style: Theme.of(context).textTheme.headline5, ), ), @@ -147,33 +148,33 @@ class GitCloneUrlKnownProviderPageState crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - 'Please create a new git repository -', + tr("setup.cloneUrl.manual.title"), style: Theme.of(context).textTheme.headline6, ), const SizedBox(height: 32.0), // Step 1 Text( - '1. Go to the website, create a repo and copy its git clone URL', + tr("setup.cloneUrl.manual.step1"), style: Theme.of(context).textTheme.subtitle2, ), const SizedBox(height: 8.0), GitHostSetupButton( - text: "Open Create New Repo Webpage", + text: tr("setup.cloneUrl.manual.button"), onPressed: widget.launchCreateUrlPage, ), const SizedBox(height: 16.0), // Step 2 Text( - '2. Enter the Git clone URL', + tr("setup.cloneUrl.manual.step1"), style: Theme.of(context).textTheme.subtitle2, ), const SizedBox(height: 8.0), inputForm, const SizedBox(height: 16.0), GitHostSetupButton( - text: "Next", + text: tr("setup.next"), onPressed: formSubmitted, ), ], @@ -185,16 +186,16 @@ class GitCloneUrlKnownProviderPageState String _isCloneUrlValid(String url) { url = url.trim(); if (url.isEmpty) { - return 'Please enter some text'; + return tr("setup.cloneUrl.validator.empty"); } var result = gitUrlParse(url); if (result == null) { - return 'Invalid Input'; + return tr("setup.cloneUrl.validator.invalid"); } if (result.protocol != 'ssh') { - return 'Only SSH urls are currently accepted'; + return tr("setup.cloneUrl.validator.onlySsh"); } return null; diff --git a/lib/setup/error.dart b/lib/setup/error.dart index 0db3e834..d934c435 100644 --- a/lib/setup/error.dart +++ b/lib/setup/error.dart @@ -1,5 +1,7 @@ import 'package:flutter/material.dart'; +import 'package:easy_localization/easy_localization.dart'; + class GitHostSetupErrorPage extends StatelessWidget { final String errorMessage; @@ -11,7 +13,7 @@ class GitHostSetupErrorPage extends StatelessWidget { Padding( padding: const EdgeInsets.all(8.0), child: Text( - 'Failed', + tr("setup.fail"), textAlign: TextAlign.center, style: Theme.of(context).textTheme.headline4, ), diff --git a/lib/setup/key_editors.dart b/lib/setup/key_editors.dart index adc8d9af..005fbb0a 100644 --- a/lib/setup/key_editors.dart +++ b/lib/setup/key_editors.dart @@ -1,5 +1,7 @@ import 'package:flutter/material.dart'; +import 'package:easy_localization/easy_localization.dart'; + class PublicKeyEditor extends StatelessWidget { final Key formKey; final TextEditingController _controller; @@ -14,7 +16,7 @@ class PublicKeyEditor extends StatelessWidget { String _validator(String val) { val = val.trim(); if (!val.startsWith("ssh-rsa ")) { - return "Invalid Public Key - Doesn't start with ssh-rsa"; + return tr("setup.keyEditors.public"); } return null; } @@ -34,10 +36,10 @@ class PrivateKeyEditor extends StatelessWidget { String _validator(String val) { val = val.trim(); if (!val.startsWith("-----BEGIN ")) { - return "Invalid Private Key"; + return tr("setup.keyEditors.private"); } if (!val.endsWith("PRIVATE KEY-----")) { - return "Invalid Private Key"; + return tr("setup.keyEditors.private"); } return null; diff --git a/lib/setup/repo_selector.dart b/lib/setup/repo_selector.dart index ef233b57..94d969ba 100644 --- a/lib/setup/repo_selector.dart +++ b/lib/setup/repo_selector.dart @@ -183,7 +183,7 @@ class GitHostSetupRepoSelectorState extends State { Opacity( opacity: canContinue ? 1.0 : 0.0, child: GitHostSetupButton( - text: tr('setup.repoSelector.next'), + text: tr('setup.next'), onPressed: () async { if (selectedRepo != null) { widget.onDone(selectedRepo);