Skip to content

Commit

Permalink
Modify how the Visual Studio add-in filters BCP-47 codes in namespaces.
Browse files Browse the repository at this point in the history
  • Loading branch information
rudyhuyn committed Aug 17, 2020
1 parent 499cafe commit f44b81c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using System.Linq;
using System.Text.RegularExpressions;
using ReswPlus.Core.ResourceInfo;
using System.Globalization;

namespace ReswPlus.Core.ClassGenerator
{
Expand Down Expand Up @@ -226,15 +227,15 @@ private string[] ExtractNamespace(string defaultNamespace)
}

// remove bcp47 tag from the namespace
var regexNamespace =
new Regex("\\.Strings\\.[a-z]{2}(?:[-_](?:Latn|Cyrl|Hant|Hans))?(?:[-_](?:\\d{3}|[A-Z]{2,3}))?$");
var match = regexNamespace.Match(defaultNamespace);
if (match.Success)
var splittedNamespace = defaultNamespace.Split('.');
var lastNamespace = splittedNamespace.Last().Replace('_', '-');
var culture = CultureInfo.GetCultures(CultureTypes.AllCultures).FirstOrDefault(c => string.Compare(c.Name, lastNamespace, true) == 0);
if (culture != null)
{
return defaultNamespace.Substring(0, match.Index + 8).Split('.');
return splittedNamespace.Take(splittedNamespace.Length - 1).ToArray();
}

return defaultNamespace.Split('.');
return splittedNamespace;
}

public static (string format, bool isDotNetFormatting) ParseTag(string comment)
Expand Down
2 changes: 1 addition & 1 deletion src/VSExtension/ReswPlus.Core/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace ReswPlus.Core
public sealed class Constants
{
public const string ReswPlusName = "DotNetPlus.ReswPlus";
public const string ReswPlusExtensionVersion = "2.1.2";
public const string ReswPlusExtensionVersion = "2.1.3";
public static Version ReswPlusLibMinVersion = new Version(1, 0, 0);
}
}
2 changes: 1 addition & 1 deletion src/VSExtension/ReswPlusVSIX/source.extension.vsixmanifest
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
<Metadata>
<Identity Id="ReswPlus.08b03f0c-a947-485c-a7a5-e351c75fad1a" Version="2.1.2" Language="en-US" Publisher="rudyhuyn" />
<Identity Id="ReswPlus.08b03f0c-a947-485c-a7a5-e351c75fad1a" Version="2.1.3" Language="en-US" Publisher="rudyhuyn" />
<DisplayName>ReswPlus - Advanced Code Generator for .Resw</DisplayName>
<Description xml:space="preserve">Advanced Resw File Code Generator for UWP apps.

Expand Down

0 comments on commit f44b81c

Please sign in to comment.