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
2 changes: 1 addition & 1 deletion src/BloomExe/Book/Book.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5406,7 +5406,7 @@ public void UpdateSupportFiles()
BookStorage.UpdateQrCode(
OurHtmlDom,
CollectionSettings.ShowBlorgLanguageQrCode,
Language1Tag,
CollectionSettings.PrimaryLangTagWithSignPrioritized,
CollectionSettings.BadgeQrCodeLabelLocalizedWithLang,
FolderPath
);
Expand Down
9 changes: 8 additions & 1 deletion src/BloomExe/Collection/CollectionSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ public string BadgeQrCodeLabelLocalizedWithLang
var pattern = BadgeQrCodeLabelLocalized;
try
{
return string.Format(pattern, Language1.Name);
return string.Format(pattern, PrimaryLanguageWithSignPrioritized);
}
catch (FormatException)
{
Expand All @@ -431,6 +431,13 @@ public string BadgeQrCodeLabelLocalizedWithLang
}
}

// For the Books on Blorg Progress Bar and QR Code, if a Sign Language is defined, we use that.
public string PrimaryLangTagWithSignPrioritized =>
string.IsNullOrEmpty(SignLanguageTag) ? Language1Tag : SignLanguageTag;

public string PrimaryLanguageWithSignPrioritized =>
string.IsNullOrEmpty(SignLanguageTag) ? Language1.Name : SignLanguage.Name;

public string BadgeQrCodeLabelLocalized
{
get
Expand Down
6 changes: 2 additions & 4 deletions src/BloomExe/web/controllers/CollectionApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -403,14 +403,12 @@ private void HandleRemoveSourceFolder(ApiRequest request)
}
}

// Currently only used by Books on Blorg Progress Bar; if a Sign Language is defined, we use that.
// Currently only used by Books on Blorg Progress Bar
private void HandleGetBookCountByLanguage(ApiRequest request)
{
if (request.HttpMethod == HttpMethods.Post)
return; // should be Get
var langTag = string.IsNullOrEmpty(_settings.SignLanguageTag)
? _settings.Language1Tag
: _settings.SignLanguageTag;
var langTag = _settings.PrimaryLangTagWithSignPrioritized;
var bloomLibraryApiClient = new BloomLibraryBookApiClient();
int count;
try
Expand Down
37 changes: 37 additions & 0 deletions src/BloomTests/Collection/CollectionSettingsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,43 @@ public void Language1TagChanged_NameChangedToo()
Assert.AreEqual("English", settings.Language1.GetNameInLanguage("en"));
}

[Test]
public void PrimaryLanguage_WithoutSignLanguage_UsesLanguage1()
{
var settings = new CollectionSettings();
settings.Language1Tag = "abc";
settings.Language1.SetName("Language One", true);
settings.BadgeQrCodeLabel = "Get more books in the {0} language on BloomLibrary.org.";

Assert.That(settings.PrimaryLangTagWithSignPrioritized, Is.EqualTo("abc"));
Assert.That(settings.PrimaryLanguageWithSignPrioritized, Is.EqualTo("Language One"));
Assert.That(
settings.BadgeQrCodeLabelLocalizedWithLang,
Is.EqualTo("Get more books in the Language One language on BloomLibrary.org.")
);
}

[Test]
public void PrimaryLanguage_WithSignLanguage_UsesSignLanguage()
{
var settings = new CollectionSettings();
settings.Language1Tag = "abc";
settings.Language1.SetName("Language One", true);
settings.SignLanguageTag = "sgn";
settings.SignLanguage.SetName("Sign Language Name", true);
settings.BadgeQrCodeLabel = "Get more books in the {0} language on BloomLibrary.org.";

Assert.That(settings.PrimaryLangTagWithSignPrioritized, Is.EqualTo("sgn"));
Assert.That(
settings.PrimaryLanguageWithSignPrioritized,
Is.EqualTo("Sign Language Name")
);
Assert.That(
settings.BadgeQrCodeLabelLocalizedWithLang,
Is.EqualTo("Get more books in the Sign Language Name language on BloomLibrary.org.")
);
}

[Test]
public void PageNumberStyle_BadNameInFile()
{
Expand Down