Skip to content
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
3 changes: 3 additions & 0 deletions src/TextMateSharp.Grammars/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
using System.Runtime.CompilerServices;

[assembly: InternalsVisibleTo("TextMateSharp.Tests")]
2 changes: 1 addition & 1 deletion src/TextMateSharp.Grammars/Resources/ResourceLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ internal class ResourceLoader

internal static Stream OpenGrammarPackage(string grammarName)
{
string grammarPackage = GrammarPrefix + grammarName.ToLower() + "." + "package.json";
string grammarPackage = GrammarPrefix + grammarName.ToLowerInvariant() + "." + "package.json";

var result = typeof(ResourceLoader).GetTypeInfo().Assembly.GetManifestResourceStream(
grammarPackage);
Expand Down
27 changes: 27 additions & 0 deletions src/TextMateSharp.Tests/Internal/Grammars/GrammarTests.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;

using NUnit.Framework;
using TextMateSharp.Grammars;
using TextMateSharp.Grammars.Resources;
using TextMateSharp.Internal.Grammars.Reader;
using TextMateSharp.Internal.Themes.Reader;
using TextMateSharp.Internal.Types;
Expand Down Expand Up @@ -267,6 +269,31 @@ public void Grammar_Should_Inject_Other_Grammars()
"meta.brace.round.ts");
}

[Test]
public void Resource_Loader_Should_Work_With_Turkish_Culture()
{
var currentCultureBck = CultureInfo.CurrentCulture;
try
{
SetCurrentCulture(CultureInfo.GetCultureInfo("tr-TR"));
using var stream = ResourceLoader.OpenGrammarPackage("Ini");
Assert.IsNotNull(stream);
}
finally
{
SetCurrentCulture(currentCultureBck);
}
}

static void SetCurrentCulture(CultureInfo cultureInfo)
{
if (cultureInfo == null)
return;

CultureInfo.CurrentCulture = cultureInfo;
CultureInfo.DefaultThreadCurrentCulture = CultureInfo.CurrentCulture;
}

static void AssertTokenValuesAreEqual(IToken token, int startIndex, int endIndex, params string[] scopes)
{
Assert.AreEqual(startIndex, token.StartIndex, "Unexpected token startIndex");
Expand Down