mirror of
https://github.com/OpenMW/openmw.git
synced 2025-03-31 16:36:41 +00:00
Build localization path using VFS::Path::Normalized
This commit is contained in:
parent
84adb0a148
commit
ffbeb5ab98
3 changed files with 24 additions and 5 deletions
|
@ -72,6 +72,13 @@ namespace VFS::Path
|
||||||
EXPECT_EQ(value.value(), "foo/bar/baz");
|
EXPECT_EQ(value.value(), "foo/bar/baz");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(NormalizedTest, shouldSupportOperatorDivEqualWithStringView)
|
||||||
|
{
|
||||||
|
Normalized value("foo/bar");
|
||||||
|
value /= std::string_view("BAZ");
|
||||||
|
EXPECT_EQ(value.value(), "foo/bar/baz");
|
||||||
|
}
|
||||||
|
|
||||||
TEST(NormalizedTest, changeExtensionShouldReplaceAfterLastDot)
|
TEST(NormalizedTest, changeExtensionShouldReplaceAfterLastDot)
|
||||||
{
|
{
|
||||||
Normalized value("foo/bar.a");
|
Normalized value("foo/bar.a");
|
||||||
|
|
|
@ -36,11 +36,13 @@ namespace l10n
|
||||||
|
|
||||||
void Manager::readLangData(const std::string& name, MessageBundles& ctx, const icu::Locale& lang)
|
void Manager::readLangData(const std::string& name, MessageBundles& ctx, const icu::Locale& lang)
|
||||||
{
|
{
|
||||||
std::string path = "l10n/";
|
std::string langName(lang.getName());
|
||||||
path.append(name);
|
langName += ".yaml";
|
||||||
path.append("/");
|
|
||||||
path.append(lang.getName());
|
VFS::Path::Normalized path("l10n");
|
||||||
path.append(".yaml");
|
path /= name;
|
||||||
|
path /= langName;
|
||||||
|
|
||||||
if (!mVFS->exists(path))
|
if (!mVFS->exists(path))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -187,6 +187,16 @@ namespace VFS::Path
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Normalized& operator/=(std::string_view value)
|
||||||
|
{
|
||||||
|
mValue.reserve(mValue.size() + value.size() + 1);
|
||||||
|
mValue += separator;
|
||||||
|
const std::size_t offset = mValue.size();
|
||||||
|
mValue += value;
|
||||||
|
normalizeFilenameInPlace(mValue.begin() + offset, mValue.end());
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
friend bool operator==(const Normalized& lhs, const Normalized& rhs) = default;
|
friend bool operator==(const Normalized& lhs, const Normalized& rhs) = default;
|
||||||
|
|
||||||
friend bool operator==(const Normalized& lhs, const auto& rhs) { return lhs.mValue == rhs; }
|
friend bool operator==(const Normalized& lhs, const auto& rhs) { return lhs.mValue == rhs; }
|
||||||
|
|
Loading…
Reference in a new issue