diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5a172e5d..8bc06852 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -28,6 +28,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Fixed
+- [SIL.LCModel] `CreateNewLangProj` no longer throws when no anthropology list file is passed and the default analysis writing system's ICU locale differs from its language tag (e.g. `pt-BR`)
- [SIL.LCModel] BaseStyleInfo now loads default font features (ktptFontVariations) from style rules, fixing font features set as style defaults being dropped on reload (LT-22351)
- [SIL.LCModel] BaseStyleInfo no longer clobbers ws-specific font overrides inherited from a based-on style with the default font info's merely-inherited values; only explicitly-set default properties are propagated to ws overrides (LT-22351)
- [SIL.LCModel] BulletInfo now decodes all properties of an encoded bullet font info instead of stopping at the first string property, fixing bullet font features (ktptFontVariations) being lost when a bullet font name was also set (LT-22351)
diff --git a/src/SIL.LCModel/LcmCache.cs b/src/SIL.LCModel/LcmCache.cs
index 1b183ff6..19bd0846 100644
--- a/src/SIL.LCModel/LcmCache.cs
+++ b/src/SIL.LCModel/LcmCache.cs
@@ -472,7 +472,7 @@ public static string CreateNewLangProj(IThreadedProgress progressDlg, params obj
cache.ActionHandlerAccessor.BeginNonUndoableTask();
InitializeAnthroList(cache.LangProject,
- cache.WritingSystemFactory.GetWsFromStr(analWrtSys != null ? analWrtSys.IcuLocale : userIcuLocale),
+ cache.WritingSystemFactory.GetWsFromStr(analWrtSys != null ? analWrtSys.Id : userIcuLocale),
(parameters.Length > 8) ? (string) parameters[8] : null);
ImportLocalizedLists(cache, dirs.TemplateDirectory, progressDlg);
cache.ActionHandlerAccessor.EndNonUndoableTask();
diff --git a/tests/SIL.LCModel.Tests/LcmCacheTests.cs b/tests/SIL.LCModel.Tests/LcmCacheTests.cs
index cab14701..3f4aff5f 100644
--- a/tests/SIL.LCModel.Tests/LcmCacheTests.cs
+++ b/tests/SIL.LCModel.Tests/LcmCacheTests.cs
@@ -147,6 +147,40 @@ public void CreateNewLangProject_AnthropologyCategoriesExist()
}
}
+ ///
+ /// The empty Anthropology Categories list is named in the default analysis writing system. That must work
+ /// when the writing system's ICU locale differs from its language tag ("pt_BR" vs "pt-BR").
+ ///
+ [Test]
+ public void CreateNewLangProject_DefaultAnalysisWsWithIcuLocaleDifferentFromTag()
+ {
+ const string dbName = "AnthroListPtBrTest";
+ SureRemoveDb(dbName);
+ var preExistingDirs = new List(Directory.GetDirectories(m_projectsDirectory));
+ try
+ {
+ var analWs = new CoreWritingSystemDefinition("pt-BR") { Id = "pt-BR" };
+ Assert.AreNotEqual(analWs.LanguageTag, analWs.IcuLocale, "Test setup: the tag and ICU locale should differ");
+ string dbFileName = LcmCache.CreateNewLangProj(new DummyProgressDlg(), dbName, m_lcmDirectories,
+ new SingleThreadedSynchronizeInvoke(), analWs, new CoreWritingSystemDefinition("fr") { Id = "fr" }, "en",
+ new HashSet(), new HashSet(), null);
+
+ var projectId = new TestProjectId(BackendProviderType.kXMLWithMemoryOnlyWsMgr, dbFileName);
+ using (var cache = LcmCache.CreateCacheFromExistingData(projectId, "en", m_ui, m_lcmDirectories, new LcmSettings(),
+ new DummyProgressDlg()))
+ {
+ var ptBr = cache.ServiceLocator.WritingSystemManager.Get("pt-BR");
+ Assert.AreEqual(ptBr, cache.LangProject.DefaultAnalysisWritingSystem);
+ Assert.AreEqual(Strings.ksAnthropologyCategories, cache.LangProject.AnthroListOA.Name.get_String(ptBr.Handle).Text);
+ Assert.AreEqual(Strings.ksAnth, cache.LangProject.AnthroListOA.Abbreviation.get_String(ptBr.Handle).Text);
+ }
+ }
+ finally
+ {
+ RemoveTestDirs(preExistingDirs, Directory.GetDirectories(m_projectsDirectory));
+ }
+ }
+
#region Private helper methods
///
/// Removes a FW DB directory, and ensures the location is promptly available for reuse