[desktop] Display type names

Signed-off-by: Dobri Dabar <dobridabar@noreply.codeberg.org>
Co-authored-by: Dobri Dabar <dobridabar@noreply.codeberg.org>
Co-committed-by: Dobri Dabar <dobridabar@noreply.codeberg.org>
This commit is contained in:
Dobri Dabar
2025-12-15 19:36:29 +01:00
committed by x7z4w
parent 3c082b0629
commit 4691de7a66
6 changed files with 91 additions and 1 deletions

2
.gitignore vendored
View File

@@ -155,6 +155,8 @@ android/huawei-appgallery.json
android/res/xml/network_security_config.xml android/res/xml/network_security_config.xml
./server/ ./server/
iphone/Maps/app.omaps/ iphone/Maps/app.omaps/
# Generated file
libs/indexer/localized_types_map.cpp
*.li *.li

View File

@@ -116,6 +116,9 @@ fi
echo "Generating search categories / synonyms..." echo "Generating search categories / synonyms..."
./tools/unix/generate_categories.sh ./tools/unix/generate_categories.sh
echo "Generating Desktop UI strings..."
./tools/unix/generate_desktop_ui_strings.sh
if [ -z "$SKIP_GENERATE_SYMBOLS" ]; then if [ -z "$SKIP_GENERATE_SYMBOLS" ]; then
if Diff data/symbols_hash data/styles/*/*/symbols/* || [ ! -z "$SYMBOLS_NOT_GENERATED" ]; then if Diff data/symbols_hash data/styles/*/*/symbols/* || [ ! -z "$SYMBOLS_NOT_GENERATED" ]; then
echo "Generating symbols..." echo "Generating symbols..."

View File

@@ -95,6 +95,9 @@ set(SRC
interval_index_builder.hpp interval_index_builder.hpp
isolines_info.cpp isolines_info.cpp
isolines_info.hpp isolines_info.hpp
localized_types_map.cpp
map_object.cpp map_object.cpp
map_object.hpp map_object.hpp
map_style.cpp map_style.cpp

View File

@@ -1,11 +1,17 @@
#include <ctime> #include <ctime>
#include "platform/localization.hpp" #include "platform/localization.hpp"
#include "indexer/localized_types_map.cpp"
namespace platform namespace platform
{ {
std::string GetLocalizedTypeName(std::string const & type) std::string GetLocalizedTypeName(std::string const & type)
{ {
return type; auto key = "type." + type;
std::replace(key.begin(), key.end(), '-', '.');
std::replace(key.begin(), key.end(), ':', '_');
auto const it = g_type2localizedType.find(key);
std::string localizedName = (it != g_type2localizedType.end()) ? it->second : std::string();
return localizedName.empty() ? type : localizedName;
} }
std::string GetLocalizedBrandName(std::string const & brand) std::string GetLocalizedBrandName(std::string const & brand)

View File

@@ -0,0 +1,74 @@
#!/usr/bin/env python3
"""
Generate localized_types_map.cpp from LocalizableTypes.strings
This script converts the iOS LocalizableTypes.strings file format to the desktop
localized_types_map.cpp C++ map by:
- Removing comments (/* ... */)
- Removing empty lines
- Converting from "key" = "value"; format to key=value format
- Removing unnecessary quotes and spaces
"""
import re
import os
import sys
from pathlib import Path
def parse_localizable_types_line(line):
line = line.strip()
if not line:
return None
if line.startswith('/*') or line.startswith('//') or line.startswith('/****'):
return None
# Match pattern: "key" = "value";
match = re.match(r'^"([^"]+)"\s*=\s*"([^"]*)"\s*;?\s*$', line)
if match:
key = match.group(1)
value = match.group(2)
return (key, value)
return None
def convert_to_localized_types_cpp(input_file, output_file):
with open(input_file, 'r', encoding='utf-8') as f:
lines = f.readlines()
entries = []
for line_num, line in enumerate(lines, 1):
try:
parsed = parse_localizable_types_line(line)
if parsed:
key, value = parsed
entries.append((key, value))
except Exception as e:
print(f"Warning: Error parsing line {line_num}: {e}")
print(f" Line content: {line.strip()}")
continue
with open(output_file, 'w', encoding='utf-8') as f:
f.write('#pragma once\n\n')
f.write('#include <string>\n')
f.write('#include <unordered_map>\n\n')
f.write('// This file is generated automatically. Do not edit.\n')
f.write('// See: tools/python/generate_desktop_ui_strings.py\n')
f.write('using Type2LocalizedType = std::unordered_map<std::string, std::string>;\n')
f.write('const Type2LocalizedType g_type2localizedType = {\n')
for i, (key, value) in enumerate(entries):
comma = ',' if i < len(entries) - 1 else ''
f.write(f' {{"{key}", "{value}"}}{comma}\n')
f.write('};\n')
print(f"Successfully converted {len(entries)} entries from '{input_file}' to '{output_file}'")
def main():
input_file = Path('iphone/Maps/LocalizedStrings/en.lproj/LocalizableTypes.strings')
output_file = Path('libs/indexer/localized_types_map.cpp')
convert_to_localized_types_cpp(str(input_file), str(output_file))
if __name__ == '__main__':
sys.exit(main())

View File

@@ -0,0 +1,2 @@
#!/usr/bin/env sh
./tools/python/generate_desktop_ui_strings.py