From 73078e31c94d84d2ccd017a5c308c3ab0934f172 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Sat, 10 Feb 2018 16:10:40 +0100 Subject: [PATCH] Added some loc work for documents --- Logic/Support/Document.cs | 53 +++++++++++--------- Site/Pages/v5/Ledgers/ViewVatReports.aspx.cs | 7 ++- 2 files changed, 35 insertions(+), 25 deletions(-) diff --git a/Logic/Support/Document.cs b/Logic/Support/Document.cs index ffd3e6b5..b209adf6 100644 --- a/Logic/Support/Document.cs +++ b/Logic/Support/Document.cs @@ -45,30 +45,7 @@ namespace Swarmops.Logic.Support int currentPage = Int32.Parse(match.Groups["current"].Value); int totalPages = Int32.Parse(match.Groups["total"].Value); - if (currentPage == 1 && totalPages == 1) - { - // Single page - - return input + Resources.Logic_Support_Document.PageSingle; - } - - if (currentPage == 1) - { - // First page of X - - return input + String.Format(Resources.Logic_Support_Document.PageOneOfX, totalPages); - } - - if (currentPage == totalPages) - { - // Last page of X - - return input + String.Format(Resources.Logic_Support_Document.LastPageOfX, totalPages); - } - - // Page X of Y - - return input + String.Format(Resources.Logic_Support_Document.PageXofY, currentPage, totalPages); + return input + GetLocalizedPageCounter(currentPage, totalPages); } // No localization @@ -105,6 +82,34 @@ namespace Swarmops.Logic.Support } } + public static string GetLocalizedPageCounter(int currentPage, int totalPages) + { + if (currentPage == 1 && totalPages == 1) + { + // Single page + + return Resources.Logic_Support_Document.PageSingle; + } + + if (currentPage == 1) + { + // First page of X + + return String.Format(Resources.Logic_Support_Document.PageOneOfX, totalPages); + } + + if (currentPage == totalPages) + { + // Last page of X + + return String.Format(Resources.Logic_Support_Document.LastPageOfX, totalPages); + } + + // Page X of Y + + return String.Format(Resources.Logic_Support_Document.PageXofY, currentPage, totalPages); + } + public static string StorageRoot { get diff --git a/Site/Pages/v5/Ledgers/ViewVatReports.aspx.cs b/Site/Pages/v5/Ledgers/ViewVatReports.aspx.cs index 6a3fd921..f2fc1f9c 100644 --- a/Site/Pages/v5/Ledgers/ViewVatReports.aspx.cs +++ b/Site/Pages/v5/Ledgers/ViewVatReports.aspx.cs @@ -116,13 +116,18 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers Documents documents = Documents.ForObject(tx.Dependency ?? tx); // tx.Dependency if not null, else tx + int pageCounter = 0; + int pagesTotal = documents.Count; + foreach (Document doc in documents) { + pageCounter++; + VatReportDocuments.Add(new RepeatedDocument { BaseId = item.FinancialTransactionId.ToString(CultureInfo.InvariantCulture), DocId = doc.Identity, - Title = tx.Description + Title = tx.Description + " " + Document.GetLocalizedPageCounter(pageCounter, pagesTotal) }); } }