Build localization path using VFS::Path::Normalized

fix-osga-rotate-wildly
elsid 3 months ago
parent 84adb0a148
commit ffbeb5ab98
No known key found for this signature in database
GPG Key ID: 4DE04C198CBA7625

@ -72,6 +72,13 @@ namespace VFS::Path
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)
{
Normalized value("foo/bar.a");

@ -36,11 +36,13 @@ namespace l10n
void Manager::readLangData(const std::string& name, MessageBundles& ctx, const icu::Locale& lang)
{
std::string path = "l10n/";
path.append(name);
path.append("/");
path.append(lang.getName());
path.append(".yaml");
std::string langName(lang.getName());
langName += ".yaml";
VFS::Path::Normalized path("l10n");
path /= name;
path /= langName;
if (!mVFS->exists(path))
return;

@ -187,6 +187,16 @@ namespace VFS::Path
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 auto& rhs) { return lhs.mValue == rhs; }

Loading…
Cancel
Save