Skip to content

Commit

Permalink
Merge pull request #3716 from cisagov/feature/CSET-2550
Browse files Browse the repository at this point in the history
Added logic for language translation of Gallery page
  • Loading branch information
Marcus-Goectau authored Jan 31, 2024
2 parents 40ab7c2 + 11739f4 commit 8f6aba5
Show file tree
Hide file tree
Showing 11 changed files with 770 additions and 58 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
{
"pairs": [
{
"key": "1",
"value": "Популярні Оцінки"
},
{
"key": "2",
"value": "CISA Спонсоровані (Стійкість та Зрілість)"
},
{
"key": "3",
"value": "Промислові та Комунальні Послуги"
},
{
"key": "4",
"value": "Моделі Зрілості"
},
{
"key": "5",
"value": "Муніципальні та Медичні Служби"
},
{
"key": "6",
"value": "NIST Спеціальні Публікації"
},
{
"key": "7",
"value": "Хімічна, Нафтова та Природний Газ"
},
{
"key": "8",
"value": "Топ Хіти"
},
{
"key": "9",
"value": "Енергетика та Електрика"
},
{
"key": "10",
"value": "Фінансові"
},
{
"key": "11",
"value": "Керування Процесами та SCADA"
},
{
"key": "12",
"value": "Ядерні"
},
{
"key": "13",
"value": "Транспорт"
},
{
"key": "14",
"value": "DoDI та CNSSI"
},
{
"key": "15",
"value": "Інші"
},
{
"key": "16",
"value": "Моделі Зрілості"
},
{
"key": "17",
"value": "Промислові Найкращі Практики"
},
{
"key": "18",
"value": "Найкращі Практики"
},
{
"key": "19",
"value": "Загальні Стандарти"
},
{
"key": "20",
"value": "Сім'я NIST SP 800-53"
},
{
"key": "21",
"value": "Хімічна, Нафтова та Природний Газ"
},
{
"key": "22",
"value": "Інші Урядові"
},
{
"key": "23",
"value": "Електрика"
},
{
"key": "24",
"value": "Фінансові"
},
{
"key": "25",
"value": "Керування Процесами та SCADA"
},
{
"key": "26",
"value": "Ядерні"
},
{
"key": "27",
"value": "TSA Спонсоровані Оцінки"
},
{
"key": "28",
"value": "DoDI та CNSSI"
},
{
"key": "29",
"value": "Інші"
},
{
"key": "30",
"value": "Центр для Інтернет Безпеки (CIS) Оцінки"
},
{
"key": "31",
"value": "Оцінки на Основі Діаграм Архітектури"
},
{
"key": "32",
"value": "Індивідуальні Деривати"
},
{
"key": "33",
"value": "Промислові Уподобання"
},
{
"key": "34",
"value": "Популярні Оцінки"
},
{
"key": "35",
"value": "Адміністрація Національного Кредитового Союзу (NCUA)"
},
{
"key": "54",
"value": "Транспорт"
},
{
"key": "67",
"value": "Мережева Діаграма"
},
{
"key": "71",
"value": "Фінансові"
},
{
"key": "72",
"value": "Фінансові Онлайн"
},
{
"key": "73",
"value": "Фінансові CSET"
},
{
"key": "74",
"value": "Основні Оцінки TSA"
},
{
"key": "75",
"value": "Тимчасові для C2M2"
},
{
"key": "76",
"value": "Індивідуальні"
},
{
"key": "77",
"value": "Популярні Оцінки"
},
{
"key": "78",
"value": "Оцінки Кібер ЗАХИСТ"
},
{
"key": "79",
"value": "Оцінки на Основі Діаграм Архітектури"
}
]
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,12 @@
<None Update="App_Data\LanguagePacks\UK\DEMOGRAPHICS_SIZE.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="App_Data\LanguagePacks\UK\GALLERY_GROUP.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="App_Data\LanguagePacks\UK\GALLERY_ITEM.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="App_Data\LanguagePacks\UK\MATURITY_QUESTIONS.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,36 @@
using System.Text.Json;
using System.Text.Json.Serialization;
using Nelibur.ObjectMapper;
using CSETWebCore.Interfaces.Helpers;

namespace CSETWebCore.Business.GalleryParser
{

public class GalleryState : IGalleryState
{
private readonly ITokenManager _token;
private CSETContext _context;
private IMaturityBusiness _maturity_business;
private IStandardsBusiness _standardsBusiness;
private IQuestionRequirementManager _questionRequirementMananger;

private readonly TranslationOverlay _overlay;


/// <summary>
///
/// </summary>
public GalleryState(CSETContext context, IMaturityBusiness maturityBusiness
public GalleryState(ITokenManager token, CSETContext context, IMaturityBusiness maturityBusiness
, IStandardsBusiness standardsBusiness
, IQuestionRequirementManager questionRequirementManager)
{
_token = token;
_context = context;
_maturity_business = maturityBusiness;
_standardsBusiness = standardsBusiness;
_questionRequirementMananger = questionRequirementManager;

_overlay = new TranslationOverlay();
}


Expand All @@ -58,6 +65,7 @@ join i in _context.GALLERY_ITEM on d.Gallery_Item_Guid equals i.Gallery_Item_Gui
select new { r, g, d, i };
var rvalue = new GalleryBoardData();

var lang = _token.GetCurrentLanguage();

int row = -1;
GalleryGroup galleryGroup = null;
Expand All @@ -71,11 +79,29 @@ join i in _context.GALLERY_ITEM on d.Gallery_Item_Guid equals i.Gallery_Item_Gui
galleryGroup.Group_Id = item.g.Group_Id;
rvalue.Rows.Add(galleryGroup);
row = item.r.Row_Index;

if (lang != "en")
{
galleryGroup.Group_Title = _overlay.GetValue("GALLERY_GROUP", galleryGroup.Group_Id.ToString(), lang)?.Value;
}
}

if ((bool)item.i.Is_Visible)
{
galleryGroup.GalleryItems.Add(new GalleryItem(item.i, galleryGroup.Group_Id));
var galleryItem = new GalleryItem(item.i, galleryGroup.Group_Id);

if (lang != "en")
{
var itemOverlay = _overlay.GetJObject("GALLERY_ITEM", "key", galleryItem.Gallery_Item_Guid.ToString(), lang);

if (itemOverlay != null)
{
galleryItem.Title = itemOverlay.Value<string>("title");
galleryItem.Description = itemOverlay.Value<string>("description");
}
}

galleryGroup.GalleryItems.Add(galleryItem);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,26 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
-------------------------->
<div class="d-flex flex-column justify-content-center flex-11a h-100 w-100">
<div class="d-flex flex-column justify-content-center flex-11a h-100 w-100" *transloco="let t">
<div class="mat-dialog-header p-3 d-flex justify-content-start align-items-center flex-00a">
<span class="fs-base-6 mr-3"><i class="fa-solid fa-file"></i></span>
<span>Assesment Description</span>
<span>{{t('titles.assessment description')}}</span>
</div>
<mat-dialog-content class="pb-0 p-3 pr-0 oy-auto d-flex flex-column flex-11a h-100"
style="position:relative; overflow-x:hidden;">
<div class="card-image-parent">
<img class="card-image-child" src="{{data.path}}">
</div>
<div class="p-4">
<div class="p-4" style="z-index: 100">
<h3 class="mb-4">{{ data.title }}</h3>
<div [innerHTML]="data.description">
</div>
</div>
<div class="card-image-parent">
<img class="card-image-child" src="{{data.path}}">
</div>
</mat-dialog-content>
<mat-dialog-actions class="pb-3 pt-0 mb-0" style="padding-right: 4rem" align="end">
<button matTooltip="Close" class="btn btn-secondary" (click)="close()" style="margin-right:5px;"><i
<button [matTooltip]="t('tooltip.close')" class="btn btn-secondary" (click)="close()" style="margin-right:5px;"><i
class="fa-solid fa-xmark"></i></button>
<button matTooltip="Create Assessment" class="btn btn-primary" (click)="launchAssessment()"><i
<button [matTooltip]="t('tooltip.create assessment')" class="btn btn-primary" (click)="launchAssessment()"><i
class="fa-solid fa-play"></i></button>
</mat-dialog-actions>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<div class="input-bar">
<div class="input-bar-item" style="width:300px;">
<div class="input-group" style="width:300px; padding: 20px 10px 0 20px">
<input #searchGallery type="text" class="form-control" placeholder="Search"
<input #searchGallery type="text" class="form-control" [placeholder]="t('tooltip.search')"
(keyup.enter)="changeToSearch(searchGallery.value)" aria-label="search gallery"
aria-describedby="search-gallery">
<div class="input-group-append">
Expand Down
Loading

0 comments on commit 8f6aba5

Please sign in to comment.