From 1fa1d84b12233cdf9b22c001c1f469d14c615ba2 Mon Sep 17 00:00:00 2001 From: Binrui Dong Date: Wed, 1 Sep 2021 08:27:25 +0800 Subject: [PATCH] Fix broken list of languages available (#51219) --- src/options.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/options.cpp b/src/options.cpp index 940f0c8b8ba78..ce9ac0a60da32 100644 --- a/src/options.cpp +++ b/src/options.cpp @@ -1017,12 +1017,10 @@ std::unordered_set options_manager::get_langs_with_translation_file const std::string start_str = locale_dir(); std::vector lang_dirs = get_directories_with( PATH_INFO::lang_file(), start_str, true ); - const std::size_t start_len = start_str.length(); - const std::string end_str = "/LC_MESSAGES"; std::for_each( lang_dirs.begin(), lang_dirs.end(), [&]( std::string & dir ) { - const std::size_t start = dir.find( start_str ) + start_len + 1; - const std::size_t len = dir.rfind( end_str ) - start; - dir = dir.substr( start, len ); + const std::size_t end = dir.rfind( "/LC_MESSAGES" ); + const std::size_t begin = dir.rfind( '/', end - 1 ) + 1; + dir = dir.substr( begin, end - begin ); } ); return std::unordered_set( lang_dirs.begin(), lang_dirs.end() ); #else // !LOCALIZE