From d8559a81f43c238f16435621fce933c976098ed1 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Fri, 25 Nov 2016 17:05:14 -0500 Subject: [PATCH] i18n resource strings for app extension --- src/App/Pages/Lock/LockPasswordPage.cs | 3 +- src/App/Resources/AppResources.Designer.cs | 81 +++++++++++++++++++ src/App/Resources/AppResources.resx | 27 +++++++ src/iOS.Extension/LoadingViewController.cs | 3 +- .../LockFingerprintViewController.cs | 3 +- .../LockPasswordViewController.cs | 2 +- src/iOS.Extension/LockPinViewController.cs | 2 +- .../PasswordGeneratorViewController.cs | 17 ++-- src/iOS.Extension/SetupViewController.cs | 5 +- src/iOS.Extension/SiteAddViewController.cs | 10 +-- src/iOS.Extension/SiteListViewController.cs | 17 ++-- 11 files changed, 141 insertions(+), 29 deletions(-) diff --git a/src/App/Pages/Lock/LockPasswordPage.cs b/src/App/Pages/Lock/LockPasswordPage.cs index 88cc3c051..cf4061f55 100644 --- a/src/App/Pages/Lock/LockPasswordPage.cs +++ b/src/App/Pages/Lock/LockPasswordPage.cs @@ -115,7 +115,8 @@ namespace Bit.App.Pages { if(string.IsNullOrWhiteSpace(PasswordCell.Entry.Text)) { - await DisplayAlert(AppResources.AnErrorHasOccurred, string.Format(AppResources.ValidationFieldRequired, AppResources.MasterPassword), AppResources.Ok); + await DisplayAlert(AppResources.AnErrorHasOccurred, string.Format(AppResources.ValidationFieldRequired, + AppResources.MasterPassword), AppResources.Ok); return; } diff --git a/src/App/Resources/AppResources.Designer.cs b/src/App/Resources/AppResources.Designer.cs index 5ba3badb8..5213d2107 100644 --- a/src/App/Resources/AppResources.Designer.cs +++ b/src/App/Resources/AppResources.Designer.cs @@ -304,6 +304,33 @@ namespace Bit.App.Resources { } } + /// + /// Looks up a localized string similar to Copied!. + /// + public static string Copied { + get { + return ResourceManager.GetString("Copied", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Copied password!. + /// + public static string CopiedPassword { + get { + return ResourceManager.GetString("CopiedPassword", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Copied username!. + /// + public static string CopiedUsername { + get { + return ResourceManager.GetString("CopiedUsername", resourceCulture); + } + } + /// /// Looks up a localized string similar to Copy. /// @@ -556,6 +583,24 @@ namespace Bit.App.Resources { } } + /// + /// Looks up a localized string similar to Your logins are now easily accessable from Safari, Chrome, and other supported apps.. + /// + public static string ExtensionSetup { + get { + return ResourceManager.GetString("ExtensionSetup", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to In Safari and Chrome, find bitwarden using the share icon (hint: scroll to the right on the bottom row of the share menu).. + /// + public static string ExtensionSetup2 { + get { + return ResourceManager.GetString("ExtensionSetup2", resourceCulture); + } + } + /// /// Looks up a localized string similar to Tap the bitwarden icon in the menu to launch the extension.. /// @@ -1033,6 +1078,15 @@ namespace Bit.App.Resources { } } + /// + /// Looks up a localized string similar to You must log into the main bitwarden app before you can use the extension.. + /// + public static string MustLogInMainApp { + get { + return ResourceManager.GetString("MustLogInMainApp", resourceCulture); + } + } + /// /// Looks up a localized string similar to My Vault. /// @@ -1096,6 +1150,15 @@ namespace Bit.App.Resources { } } + /// + /// Looks up a localized string similar to There are no sites in your vault for this website. Tap to add one.. + /// + public static string NoSitesTap { + get { + return ResourceManager.GetString("NoSitesTap", resourceCulture); + } + } + /// /// Looks up a localized string similar to Notes. /// @@ -1105,6 +1168,15 @@ namespace Bit.App.Resources { } } + /// + /// Looks up a localized string similar to This site does not have a username or password configured.. + /// + public static string NoUsernamePasswordConfigured { + get { + return ResourceManager.GetString("NoUsernamePasswordConfigured", resourceCulture); + } + } + /// /// Looks up a localized string similar to Ok. /// @@ -1123,6 +1195,15 @@ namespace Bit.App.Resources { } } + /// + /// Looks up a localized string similar to Option defaults are set from the main bitwarden app's password generator tool.. + /// + public static string OptionDefaults { + get { + return ResourceManager.GetString("OptionDefaults", resourceCulture); + } + } + /// /// Looks up a localized string similar to Options. /// diff --git a/src/App/Resources/AppResources.resx b/src/App/Resources/AppResources.resx index 8e0c5ef27..cdfc8600a 100644 --- a/src/App/Resources/AppResources.resx +++ b/src/App/Resources/AppResources.resx @@ -448,6 +448,15 @@ Continue + + Copied! + + + Copied password! + + + Copied username! + Create Account @@ -492,6 +501,12 @@ See Supported Apps + + Your logins are now easily accessable from Safari, Chrome, and other supported apps. + + + In Safari and Chrome, find bitwarden using the share icon (hint: scroll to the right on the bottom row of the share menu). + Tap the bitwarden icon in the menu to launch the extension. @@ -582,6 +597,9 @@ More Settings + + You must log into the main bitwarden app before you can use the extension. + Never @@ -594,10 +612,19 @@ There are no sites in your vault. + + There are no sites in your vault for this website. Tap to add one. + + + This site does not have a username or password configured. + Ok, got it! Confirmation, like "Ok, I understand it" + + Option defaults are set from the main bitwarden app's password generator tool. + Options diff --git a/src/iOS.Extension/LoadingViewController.cs b/src/iOS.Extension/LoadingViewController.cs index 4fd236c3d..71bdbb12e 100644 --- a/src/iOS.Extension/LoadingViewController.cs +++ b/src/iOS.Extension/LoadingViewController.cs @@ -90,8 +90,7 @@ namespace Bit.iOS.Extension var authService = Resolver.Resolve(); if(!authService.IsAuthenticated) { - var alert = Dialogs.CreateAlert(null, - "You must log into the main bitwarden app before you can use the extension.", AppResources.Ok, (a) => + var alert = Dialogs.CreateAlert(null, AppResources.MustLogInMainApp, AppResources.Ok, (a) => { CompleteRequest(null); }); diff --git a/src/iOS.Extension/LockFingerprintViewController.cs b/src/iOS.Extension/LockFingerprintViewController.cs index 678e30cc3..bf9010407 100644 --- a/src/iOS.Extension/LockFingerprintViewController.cs +++ b/src/iOS.Extension/LockFingerprintViewController.cs @@ -7,6 +7,7 @@ using Plugin.Fingerprint.Abstractions; using System.Threading.Tasks; using Bit.App; using Bit.iOS.Core.Controllers; +using Bit.App.Resources; namespace Bit.iOS.Extension { @@ -67,7 +68,7 @@ namespace Bit.iOS.Extension public async Task CheckFingerprintAsync() { - var result = await _fingerprint.AuthenticateAsync("Use your fingerprint to verify."); + var result = await _fingerprint.AuthenticateAsync(AppResources.FingerprintDirection); if(result.Authenticated) { _settings.AddOrUpdateValue(Constants.Locked, false); diff --git a/src/iOS.Extension/LockPasswordViewController.cs b/src/iOS.Extension/LockPasswordViewController.cs index ae646bcef..287054e72 100644 --- a/src/iOS.Extension/LockPasswordViewController.cs +++ b/src/iOS.Extension/LockPasswordViewController.cs @@ -94,7 +94,7 @@ namespace Bit.iOS.Extension // TODO: keep track of invalid attempts and logout? var alert = Dialogs.CreateAlert(AppResources.AnErrorHasOccurred, - string.Format(null, "Invalid Master Password. Try again."), AppResources.Ok, (a) => + string.Format(null, AppResources.InvalidMasterPassword), AppResources.Ok, (a) => { MasterPasswordCell.TextField.Text = string.Empty; diff --git a/src/iOS.Extension/LockPinViewController.cs b/src/iOS.Extension/LockPinViewController.cs index 219875f12..a3f99c786 100644 --- a/src/iOS.Extension/LockPinViewController.cs +++ b/src/iOS.Extension/LockPinViewController.cs @@ -73,7 +73,7 @@ namespace Bit.iOS.Extension { // TODO: keep track of invalid attempts and logout? - var alert = Dialogs.CreateAlert(null, "Invalid PIN. Try again.", AppResources.Ok, (a) => + var alert = Dialogs.CreateAlert(null, AppResources.InvalidPIN, AppResources.Ok, (a) => { PinTextField.Text = string.Empty; SetLabelText(); diff --git a/src/iOS.Extension/PasswordGeneratorViewController.cs b/src/iOS.Extension/PasswordGeneratorViewController.cs index 29599b76e..477e747e6 100644 --- a/src/iOS.Extension/PasswordGeneratorViewController.cs +++ b/src/iOS.Extension/PasswordGeneratorViewController.cs @@ -11,6 +11,7 @@ using CoreGraphics; using Bit.App; using Bit.iOS.Core.Utilities; using Bit.iOS.Core.Controllers; +using Bit.App.Resources; namespace Bit.iOS.Extension { @@ -30,9 +31,9 @@ namespace Bit.iOS.Extension public SwitchTableViewCell LowercaseCell { get; set; } = new SwitchTableViewCell("a-z"); public SwitchTableViewCell NumbersCell { get; set; } = new SwitchTableViewCell("0-9"); public SwitchTableViewCell SpecialCell { get; set; } = new SwitchTableViewCell("!@#$%^&*"); - public StepperTableViewCell MinNumbersCell { get; set; } = new StepperTableViewCell("Minimum Numbers", 1, 0, 5, 1); - public StepperTableViewCell MinSpecialCell { get; set; } = new StepperTableViewCell("Minimum Special", 1, 0, 5, 1); - public SliderTableViewCell LengthCell { get; set; } = new SliderTableViewCell("Length", 10, 5, 64); + public StepperTableViewCell MinNumbersCell { get; set; } = new StepperTableViewCell(AppResources.MinNumbers, 1, 0, 5, 1); + public StepperTableViewCell MinSpecialCell { get; set; } = new StepperTableViewCell(AppResources.MinSpecial, 1, 0, 5, 1); + public SliderTableViewCell LengthCell { get; set; } = new SliderTableViewCell(AppResources.Length, 10, 5, 64); public override void ViewWillAppear(bool animated) { @@ -202,11 +203,11 @@ namespace Bit.iOS.Extension cell.TextLabel.TextColor = new UIColor(red: 0.24f, green: 0.55f, blue: 0.74f, alpha: 1.0f); if(indexPath.Row == 0) { - cell.TextLabel.Text = "Regenerate Password"; + cell.TextLabel.Text = AppResources.RegeneratePassword; } else if(indexPath.Row == 1) { - cell.TextLabel.Text = "Copy Password"; + cell.TextLabel.Text = AppResources.CopyPassword; } return cell; } @@ -290,7 +291,7 @@ namespace Bit.iOS.Extension { if(section == 1) { - return "Options"; + return AppResources.Options; } return null; @@ -300,7 +301,7 @@ namespace Bit.iOS.Extension { if(section == 1) { - return "Option defaults are set from the main bitwarden app's password generator tool."; + return AppResources.OptionDefaults; } return null; @@ -320,7 +321,7 @@ namespace Bit.iOS.Extension _controller._googleAnalyticsService.TrackExtensionEvent("CopiedGeneratedPassword"); UIPasteboard clipboard = UIPasteboard.General; clipboard.String = _controller.PasswordLabel.Text; - var alert = Dialogs.CreateMessageAlert("Copied!"); + var alert = Dialogs.CreateMessageAlert(AppResources.Copied); _controller.PresentViewController(alert, true, () => { _controller.DismissViewController(true, null); diff --git a/src/iOS.Extension/SetupViewController.cs b/src/iOS.Extension/SetupViewController.cs index 6d1bc7a32..c61a0c919 100644 --- a/src/iOS.Extension/SetupViewController.cs +++ b/src/iOS.Extension/SetupViewController.cs @@ -3,6 +3,7 @@ using Bit.iOS.Extension.Models; using UIKit; using Plugin.Settings.Abstractions; using Bit.iOS.Core.Controllers; +using Bit.App.Resources; namespace Bit.iOS.Extension { @@ -25,9 +26,9 @@ namespace Bit.iOS.Extension { View.BackgroundColor = new UIColor(red: 0.94f, green: 0.94f, blue: 0.96f, alpha: 1.0f); var descriptor = UIFontDescriptor.PreferredBody; - DescriptionLabel.Text = @"Your logins are now easily accessable from Safari, Chrome, and other supported apps. + DescriptionLabel.Text = $@"{AppResources.ExtensionSetup} -In Safari and Chrome, find bitwarden using the share icon (hint: scroll to the right on the bottom row of the share menu)."; +{AppResources.ExtensionSetup2}"; DescriptionLabel.Font = UIFont.FromDescriptor(descriptor, descriptor.PointSize); DescriptionLabel.TextColor = new UIColor(red: 0.47f, green: 0.47f, blue: 0.47f, alpha: 1.0f); ActivatedLabel.Font = UIFont.FromDescriptor(descriptor, descriptor.PointSize * 1.3f); diff --git a/src/iOS.Extension/SiteAddViewController.cs b/src/iOS.Extension/SiteAddViewController.cs index 952e525ce..0a57ed46d 100644 --- a/src/iOS.Extension/SiteAddViewController.cs +++ b/src/iOS.Extension/SiteAddViewController.cs @@ -36,7 +36,7 @@ namespace Bit.iOS.Extension public FormEntryTableViewCell UsernameCell { get; set; } = new FormEntryTableViewCell(AppResources.Username); public FormEntryTableViewCell PasswordCell { get; set; } = new FormEntryTableViewCell(AppResources.Password); public UITableViewCell GeneratePasswordCell { get; set; } = new UITableViewCell(UITableViewCellStyle.Subtitle, "GeneratePasswordCell"); - public SwitchTableViewCell FavoriteCell { get; set; } = new SwitchTableViewCell("Favorite"); + public SwitchTableViewCell FavoriteCell { get; set; } = new SwitchTableViewCell(AppResources.Favorite); public FormEntryTableViewCell NotesCell { get; set; } = new FormEntryTableViewCell(useTextView: true, height: 90); public PickerTableViewCell FolderCell { get; set; } = new PickerTableViewCell(AppResources.Folder); @@ -91,7 +91,7 @@ namespace Bit.iOS.Extension return true; }; - GeneratePasswordCell.TextLabel.Text = "Generate Password"; + GeneratePasswordCell.TextLabel.Text = AppResources.GeneratePassword; GeneratePasswordCell.Accessory = UITableViewCellAccessory.DisclosureIndicator; _folders = _folderService.GetAllAsync().GetAwaiter().GetResult(); @@ -160,7 +160,7 @@ namespace Bit.iOS.Extension }; var saveTask = _siteService.SaveAsync(site); - var loadingAlert = Dialogs.CreateLoadingAlert("Saving..."); + var loadingAlert = Dialogs.CreateLoadingAlert(AppResources.Saving); PresentViewController(loadingAlert, true, null); await saveTask; @@ -299,11 +299,11 @@ namespace Bit.iOS.Extension { if(section == 0) { - return "Site Information"; + return AppResources.SiteInformation; } else if(section == 2) { - return "Notes"; + return AppResources.Notes; } return null; diff --git a/src/iOS.Extension/SiteListViewController.cs b/src/iOS.Extension/SiteListViewController.cs index 920b94068..1e866ffd4 100644 --- a/src/iOS.Extension/SiteListViewController.cs +++ b/src/iOS.Extension/SiteListViewController.cs @@ -13,6 +13,7 @@ using System.Threading.Tasks; using Bit.iOS.Core; using MobileCoreServices; using Bit.iOS.Core.Controllers; +using Bit.App.Resources; namespace Bit.iOS.Extension { @@ -36,7 +37,7 @@ namespace Bit.iOS.Extension base.ViewDidLoad(); if(!CanAutoFill()) { - CancelBarButton.Title = "Close"; + CancelBarButton.Title = AppResources.Close; } TableView.RowHeight = UITableView.AutomaticDimension; @@ -132,7 +133,7 @@ namespace Bit.iOS.Extension if(_tableItems.Count() == 0) { var noDataCell = new UITableViewCell(UITableViewCellStyle.Default, "NoDataCell"); - noDataCell.TextLabel.Text = "There are no sites in your vault for this website. Tap to add one."; + noDataCell.TextLabel.Text = AppResources.NoSitesTap; noDataCell.TextLabel.TextAlignment = UITextAlignment.Center; noDataCell.TextLabel.LineBreakMode = UILineBreakMode.WordWrap; noDataCell.TextLabel.Lines = 0; @@ -190,11 +191,11 @@ namespace Bit.iOS.Extension var sheet = Dialogs.CreateActionSheet(item.Name, _controller); if(!string.IsNullOrWhiteSpace(item.Username)) { - sheet.AddAction(UIAlertAction.Create("Copy Username", UIAlertActionStyle.Default, a => + sheet.AddAction(UIAlertAction.Create(AppResources.CopyUsername, UIAlertActionStyle.Default, a => { UIPasteboard clipboard = UIPasteboard.General; clipboard.String = item.Username; - var alert = Dialogs.CreateMessageAlert("Copied username!"); + var alert = Dialogs.CreateMessageAlert(AppResources.CopyUsername); _controller.PresentViewController(alert, true, () => { _controller.DismissViewController(true, null); @@ -204,11 +205,11 @@ namespace Bit.iOS.Extension if(!string.IsNullOrWhiteSpace(item.Password)) { - sheet.AddAction(UIAlertAction.Create("Copy Password", UIAlertActionStyle.Default, a => + sheet.AddAction(UIAlertAction.Create(AppResources.CopyPassword, UIAlertActionStyle.Default, a => { UIPasteboard clipboard = UIPasteboard.General; clipboard.String = item.Password; - var alert = Dialogs.CreateMessageAlert("Copied password!"); + var alert = Dialogs.CreateMessageAlert(AppResources.CopiedPassword); _controller.PresentViewController(alert, true, () => { _controller.DismissViewController(true, null); @@ -216,12 +217,12 @@ namespace Bit.iOS.Extension })); } - sheet.AddAction(UIAlertAction.Create("Cancel", UIAlertActionStyle.Cancel, null)); + sheet.AddAction(UIAlertAction.Create(AppResources.Cancel, UIAlertActionStyle.Cancel, null)); _controller.PresentViewController(sheet, true, null); } else { - var alert = Dialogs.CreateAlert(null, "This site does not have a username or password configured.", "Ok"); + var alert = Dialogs.CreateAlert(null, AppResources.NoUsernamePasswordConfigured, AppResources.Ok); _controller.PresentViewController(alert, true, null); } }