Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 0.5.5 #30

Merged
merged 6 commits into from
Nov 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [0.5.5] / 2023-11-03
### Features
- Language Update and Test

## [0.5.4] / 2023-10-19
### Features
- Add `ComboBox` methods extension
Expand Down Expand Up @@ -275,6 +279,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- First Release

[vNext]: ../../compare/1.0.0...HEAD
[0.5.5]: ../../compare/0.5.4...0.5.5
[0.5.4]: ../../compare/0.5.3...0.5.4
[0.5.3]: ../../compare/0.5.2...0.5.3
[0.5.2]: ../../compare/0.5.1...0.5.2
Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
[![Develop](../../actions/workflows/Develop.yml/badge.svg)](../../actions)
[![Release](https://img.shields.io/nuget/v/ricaun.Revit.UI?logo=nuget&label=release&color=blue)](https://www.nuget.org/packages/ricaun.Revit.UI)

This project was generated by the [ricaun.AppLoader](https://ricaun.com/AppLoader/) Revit plugin, the test project use the [ricaun.RevitTest](https://ricaun.com/RevitTest) test framework.

## Features

`ricaun.Revit.UI` package is design to work with the plugin [AppLoader](https://ricaun.com/AppLoader/) that allow loading Revit Applications on runtime.
Expand Down Expand Up @@ -323,20 +325,18 @@ BitmapSource bitmapSource = base64orUri.GetBitmapSource();
```C#
LanguageType languageType = LanguageExtension.GetLanguageType();
// LanguageExtension.IsEnglish;
// LanguageExtension.IsSpanish;
// LanguageExtension.IsRussian;
// LanguageExtension.IsHungarian;
// LanguageExtension.IsDutch;
// LanguageExtension.IsFrench;
// LanguageExtension.IsGerman;
// LanguageExtension.IsSpanish;
// LanguageExtension.IsRussian;
// LanguageExtension.IsPolish;
// LanguageExtension.IsItalian;
// LanguageExtension.IsJapanese;
// LanguageExtension.IsKorean;
// LanguageExtension.IsCzech;
// LanguageExtension.IsPolish;
// LanguageExtension.IsSpanish;
// LanguageExtension.IsChineseSimplified;
// LanguageExtension.IsChineseTraditional;
// LanguageExtension.IsBrazilianPortuguese;
// LanguageExtension.IsRussian;
// LanguageExtension.IsCzech;
```

### Ribbon Stacked Extension
Expand Down
96 changes: 96 additions & 0 deletions ricaun.Revit.UI.Tests/RevitLanguageTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
using Autodesk.Revit.ApplicationServices;
using NUnit.Framework;

namespace ricaun.Revit.UI.Tests
{
public class RevitLanguageTests
{
private Application application;
[OneTimeSetUp]
public void Setup(Application application)
{
this.application = application;
}

[Test]
public void Application_Language()
{
var language = application.Language;

var name = language.GetCultureInfoName();
Assert.IsNotNull(name);
}

[Test]
public void Languages_Valid_CultureInfoName()
{
var languages = new[]
{
LanguageType.English_USA,
LanguageType.French,
LanguageType.German,
LanguageType.Italian,
LanguageType.Japanese,
LanguageType.Korean,
LanguageType.Polish,
LanguageType.Spanish,
LanguageType.Chinese_Simplified,
LanguageType.Chinese_Traditional,
LanguageType.Brazilian_Portuguese,
LanguageType.Russian,
LanguageType.Czech,
};

foreach (var language in languages)
{
var name = language.GetCultureInfoName();
Assert.IsNotNull(name);
}
}

[Test]
public void Languages_NotValid_CultureInfoName()
{
var languages = new[]
{
LanguageType.Unknown,
LanguageType.English_GB, // Does not exist in Revit Api 2017
LanguageType.Dutch, // Not supported, how to start Revit in Dutch?
LanguageType.Hungarian, // Not supported, how to start Revit in Hungarian?
};

foreach (var language in languages)
{
var name = language.GetCultureInfoName();
Assert.IsNull(name);
}
}

[Test]
public void Languages_GetLanguageType()
{
var language = application.Language;
Assert.AreEqual(LanguageExtension.GetLanguageType(), language);
}

[Test]
public void Languages_IsLanguage()
{
var language = application.Language;
Assert.AreEqual(LanguageExtension.IsEnglish, language == LanguageType.English_USA);
Assert.AreEqual(LanguageExtension.IsFrench, language == LanguageType.French);
Assert.AreEqual(LanguageExtension.IsGerman, language == LanguageType.German);
Assert.AreEqual(LanguageExtension.IsItalian, language == LanguageType.Italian);
Assert.AreEqual(LanguageExtension.IsJapanese, language == LanguageType.Japanese);
Assert.AreEqual(LanguageExtension.IsKorean, language == LanguageType.Korean);
Assert.AreEqual(LanguageExtension.IsPolish, language == LanguageType.Polish);
Assert.AreEqual(LanguageExtension.IsSpanish, language == LanguageType.Spanish);
Assert.AreEqual(LanguageExtension.IsChineseSimplified, language == LanguageType.Chinese_Simplified);
Assert.AreEqual(LanguageExtension.IsChineseTraditional, language == LanguageType.Chinese_Traditional);
Assert.AreEqual(LanguageExtension.IsBrazilianPortuguese, language == LanguageType.Brazilian_Portuguese);
Assert.AreEqual(LanguageExtension.IsRussian, language == LanguageType.Russian);
Assert.AreEqual(LanguageExtension.IsCzech, language == LanguageType.Czech);
}
}

}
1 change: 1 addition & 0 deletions ricaun.Revit.UI.Tests/RevitTests.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using NUnit.Framework;
using System;
Expand Down
133 changes: 43 additions & 90 deletions ricaun.Revit.UI/LanguageExtension.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Autodesk.Revit.ApplicationServices;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;

namespace ricaun.Revit.UI
{
Expand All @@ -15,21 +16,33 @@ public static class LanguageExtension
/// </summary>
public static bool IsEnglish => GetLanguageType() == LanguageType.English_USA;
/// <summary>
/// Is LanguageType == LanguageType.French
/// </summary>
public static bool IsFrench => GetLanguageType() == LanguageType.French;
/// <summary>
/// Is LanguageType == LanguageType.German
/// </summary>
public static bool IsGerman => GetLanguageType() == LanguageType.German;
/// <summary>
/// Is LanguageType == LanguageType.Spanish
/// Is LanguageType == LanguageType.Italian
/// </summary>
public static bool IsSpanish => GetLanguageType() == LanguageType.Spanish;
public static bool IsItalian => GetLanguageType() == LanguageType.Italian;
/// <summary>
/// Is LanguageType == LanguageType.French
/// Is LanguageType == LanguageType.Japanese
/// </summary>
public static bool IsFrench => GetLanguageType() == LanguageType.French;
public static bool IsJapanese => GetLanguageType() == LanguageType.Japanese;
/// <summary>
/// Is LanguageType == LanguageType.Dutch
/// Is LanguageType == LanguageType.Korean
/// </summary>
public static bool IsDutch => GetLanguageType() == LanguageType.Dutch;
public static bool IsKorean => GetLanguageType() == LanguageType.Korean;
/// <summary>
/// Is LanguageType == LanguageType.Polish
/// </summary>
public static bool IsPolish => GetLanguageType() == LanguageType.Polish;
/// <summary>
/// Is LanguageType == LanguageType.Spanish
/// </summary>
public static bool IsSpanish => GetLanguageType() == LanguageType.Spanish;
/// <summary>
/// Is LanguageType == LanguageType.Chinese_Simplified
/// </summary>
Expand All @@ -39,9 +52,9 @@ public static class LanguageExtension
/// </summary>
public static bool IsChineseTraditional => GetLanguageType() == LanguageType.Chinese_Traditional;
/// <summary>
/// Is LanguageType == LanguageType.Korean
/// Is LanguageType == LanguageType.Brazilian_Portuguese
/// </summary>
public static bool IsKorean => GetLanguageType() == LanguageType.Korean;
public static bool IsBrazilianPortuguese => GetLanguageType() == LanguageType.Brazilian_Portuguese;
/// <summary>
/// Is LanguageType == LanguageType.Russian
/// </summary>
Expand All @@ -50,18 +63,6 @@ public static class LanguageExtension
/// Is LanguageType == LanguageType.Czech
/// </summary>
public static bool IsCzech => GetLanguageType() == LanguageType.Czech;
/// <summary>
/// Is LanguageType == LanguageType.Polish
/// </summary>
public static bool IsPolish => GetLanguageType() == LanguageType.Polish;
/// <summary>
/// Is LanguageType == LanguageType.Hungarian
/// </summary>
public static bool IsHungarian => GetLanguageType() == LanguageType.Hungarian;
/// <summary>
/// Is LanguageType == LanguageType.Brazilian_Portuguese
/// </summary>
public static bool IsBrazilianPortuguese => GetLanguageType() == LanguageType.Brazilian_Portuguese;
#endregion

/// <summary>
Expand All @@ -78,61 +79,13 @@ public static LanguageType GetLanguageType()
/// </summary>
/// <param name="languageType"></param>
/// <returns></returns>
/// <remarks>LanguageType.Unknown or not valid return null, check <see cref="GetLanguages"/> available.</remarks>
public static string GetCultureInfoName(this LanguageType languageType)
{
string language = "";
switch (languageType)
{
case LanguageType.Unknown:
language = "";
break;
case LanguageType.English_USA:
language = "en-US";
break;
case LanguageType.German:
language = "de-DE";
break;
case LanguageType.Spanish:
language = "es-ES";
break;
case LanguageType.French:
language = "fr-FR";
break;
case LanguageType.Italian:
language = "it-IT";
break;
case LanguageType.Dutch:
language = "nl-BE";
break;
case LanguageType.Chinese_Simplified:
language = "zh-CHS";
break;
case LanguageType.Chinese_Traditional:
language = "zh-CHT";
break;
case LanguageType.Japanese:
language = "ja-JP";
break;
case LanguageType.Korean:
language = "ko-KR";
break;
case LanguageType.Russian:
language = "ru-RU";
break;
case LanguageType.Czech:
language = "cs-CZ";
break;
case LanguageType.Polish:
language = "pl-PL";
break;
case LanguageType.Hungarian:
language = "hu-HU";
break;
case LanguageType.Brazilian_Portuguese:
language = "pt-BR";
break;
}
return language;
var findLanguage = GetLanguages()
.FirstOrDefault(x => x.Value == languageType).Key;

return findLanguage;
}

/// <summary>
Expand All @@ -141,23 +94,23 @@ public static string GetCultureInfoName(this LanguageType languageType)
/// <returns></returns>
public static Dictionary<string, LanguageType> GetLanguages()
{
var languages = new Dictionary<string, LanguageType>();

languages.Add("en-US", LanguageType.English_USA);
languages.Add("de-DE", LanguageType.German);
languages.Add("es-ES", LanguageType.Spanish);
languages.Add("fr-FR", LanguageType.French);
languages.Add("nl-BE", LanguageType.Dutch);
languages.Add("zh-CHS", LanguageType.Chinese_Simplified);
languages.Add("zh-CHT", LanguageType.Chinese_Traditional);
languages.Add("ko-KR", LanguageType.Korean);
languages.Add("ru-RU", LanguageType.Russian);
languages.Add("cs-CZ", LanguageType.Czech);
languages.Add("pl-PL", LanguageType.Polish);
languages.Add("hu-HU", LanguageType.Hungarian);
languages.Add("pt-BR", LanguageType.Brazilian_Portuguese);

return languages;
return new Dictionary<string, LanguageType>
{
{ "en-US", LanguageType.English_USA }, // English - United States
// { "en-GB", LanguageType.English_GB }, // English - United Kingdom
{ "fr-FR", LanguageType.French }, // French
{ "de-DE", LanguageType.German }, // German
{ "it-IT", LanguageType.Italian }, // Italian
{ "ja-JP", LanguageType.Japanese }, // Japanese
{ "ko-KR", LanguageType.Korean }, // Korean
{ "pl-PL", LanguageType.Polish }, // Polish
{ "es-ES", LanguageType.Spanish }, // Spanish
{ "zh-CH", LanguageType.Chinese_Simplified }, // Simplified Chinese
{ "zh-TW", LanguageType.Chinese_Traditional }, // Traditional Chinese
{ "pt-BR", LanguageType.Brazilian_Portuguese }, // Brazilian Portuguese
{ "ru-RU", LanguageType.Russian }, // Russian
{ "cs-CZ", LanguageType.Czech }, // Czech
};
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion ricaun.Revit.UI/ricaun.Revit.UI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@

<PropertyGroup>
<PackageId>ricaun.Revit.UI</PackageId>
<Version>0.5.4</Version>
<Version>0.5.5</Version>
<ProjectGuid>{2064ba4d-5527-41e9-8b76-0cbfefa35900}</ProjectGuid>
</PropertyGroup>

Expand Down