Add Search Category
1. Gather Requirements
Ask the user for:
- OSM type(s) — e.g.
shop-leather, amenity-cafe. Multiple types separated by |
- Group(s) — which
@group to attach (e.g. @shop, @category_eat). Grep ^@ in data/categories.txt for existing groups
- Emoji (optional) —
U+XXXX Unicode format, placed as synonyms on the en: line
2. Ensure Translations Exist in types_strings.txt
Convert OSM type dashes to dots: shop-leather → [type.shop.leather].
Check if the entry exists in data/strings/types_strings.txt.
If absent — create translations first:
- Ask user for the English name and translation context (what this place/thing is)
- Run translation tool:
python3 tools/python/translate.py --context "context here" "English Name"
This outputs translations in both categories.txt and strings.txt formats via DeepL+Google
- Proof-read the generated translations in all languages using the provided context — fix obvious errors
- Add the
[type.osm.type] entry to data/strings/types_strings.txt:[type.shop.leather]
comment = context used for translation
en = Leather Shop
ar = متجر السلع الجلدية
...sorted alphabetically by language code...
zh-Hant = 皮具店
If present — read existing translations to use as the base.
3. Build the categories.txt Entry
First translation = types_strings.txt match
The first synonym for each language MUST exactly match the translation in types_strings.txt. This is a hard requirement.
Additional synonyms
Append popular search synonyms after | — only terms users would actually type in the search box. Keep it minimal.
Prefix digits
A digit 1-9 before a synonym controls the minimum characters needed for the suggestion to appear:
3Cafe → user must type 3+ chars
- No prefix → full text required
Slavic language rule
For ru, uk, be: short nouns (under 6 letters) need both nominative and genitive forms:
ru:Вино|вина
For sr: threshold is 8 letters. Longer nouns rely on error correction.
4. Entry Format
osm-type1|osm-type2|@group1|@group2
en:4Type Name|synonym|U+1F6B0
ar:Arabic Name
be:Belarusian Name
...languages sorted alphabetically by code...
zh-Hant:Traditional Chinese
en: line always first after the header
- Other languages sorted alphabetically by language code
- Each entry ends with a blank line
- Insert near related categories (same group or alphabetically by OSM type)
- Supported language codes: ar, be, bg, ca, cs, da, de, el, en, es, et, eu, fa, fi, fr, he, hi, hu, id, it, ja, ko, lt, lv, mr, nb, nl, pl, pt, pt-BR, ro, ru, sk, sl, sr, sv, sw, th, tr, uk, vi, zh-Hans, zh-Hant
5. Displayed Category (@category_*)
Only if adding a category shown in the app's search screen. Requires three coordinated file changes:
a) data/categories.txt
# First keyword should match [category_name] definition in strings.txt!
@category_name
en:Display Name|synonym
...translations...
b) data/strings/strings.txt
[category_name]
comment = Search category for ...; any changes should be duplicated in categories.txt @category_name!
tags = android-app,android-libs-car,apple-maps
en = Display Name
...translations for all supported locales...
The en = value must match the first keyword on the en: line (without prefix digit).
c) libs/search/displayed_categories.cpp
Add "category_name" to the m_keys initializer list.
6. After Editing
Sort languages:
python3 tools/python/sort_categories.py --in-place
Build and run tests:
cmake --build build-agent --target search_tests && ctest -j --test-dir build-agent --stop-on-failure --output-on-failure -R search_tests
If a displayed category was added, also run:
cmake --build build-agent --target indexer_tests editor_tests && ctest -j --test-dir build-agent --stop-on-failure --output-on-failure -R "indexer_tests|editor_tests"
1---2name: add-category3description: Add a new search category (OSM type with translations, synonyms, and emoji) to data/categories.txt. Use when asked to add, create, or insert a search category, search synonym, or map feature type.4---56# Add Search Category78## 1. Gather Requirements910Ask the user for:11- **OSM type(s)** — e.g. `shop-leather`, `amenity-cafe`. Multiple types separated by `|`12- **Group(s)** — which `@group` to attach (e.g. `@shop`, `@category_eat`). Grep `^@` in `data/categories.txt` for existing groups13- **Emoji** (optional) — `U+XXXX` Unicode format, placed as synonyms on the `en:` line1415## 2. Ensure Translations Exist in types_strings.txt1617Convert OSM type dashes to dots: `shop-leather` → `[type.shop.leather]`.1819**Check** if the entry exists in `data/strings/types_strings.txt`.2021### If absent — create translations first:221. Ask user for the **English name** and **translation context** (what this place/thing is)232. Run translation tool:24 ```25 python3 tools/python/translate.py --context "context here" "English Name"26 ```27 This outputs translations in both `categories.txt` and `strings.txt` formats via DeepL+Google283. **Proof-read** the generated translations in all languages using the provided context — fix obvious errors294. Add the `[type.osm.type]` entry to `data/strings/types_strings.txt`:30 ```31 [type.shop.leather]32 comment = context used for translation33 en = Leather Shop34 ar = متجر السلع الجلدية35 ...sorted alphabetically by language code...36 zh-Hant = 皮具店37 ```3839### If present — read existing translations to use as the base.4041## 3. Build the categories.txt Entry4243### First translation = types_strings.txt match44The **first synonym** for each language MUST exactly match the translation in `types_strings.txt`. This is a hard requirement.4546### Additional synonyms47Append popular search synonyms after `|` — only terms users would actually type in the search box. Keep it minimal.4849### Prefix digits50A digit `1`-`9` before a synonym controls the minimum characters needed for the suggestion to appear:51- `3Cafe` → user must type 3+ chars52- No prefix → full text required5354### Slavic language rule55For **ru, uk, be**: short nouns (under 6 letters) need both nominative and genitive forms:56```57ru:Вино|вина58```59For **sr**: threshold is 8 letters. Longer nouns rely on error correction.6061## 4. Entry Format6263```64osm-type1|osm-type2|@group1|@group265en:4Type Name|synonym|U+1F6B066ar:Arabic Name67be:Belarusian Name68...languages sorted alphabetically by code...69zh-Hant:Traditional Chinese70```7172- `en:` line always **first** after the header73- Other languages sorted **alphabetically** by language code74- Each entry ends with a **blank line**75- Insert near related categories (same group or alphabetically by OSM type)76- Supported language codes: ar, be, bg, ca, cs, da, de, el, en, es, et, eu, fa, fi, fr, he, hi, hu, id, it, ja, ko, lt, lv, mr, nb, nl, pl, pt, pt-BR, ro, ru, sk, sl, sr, sv, sw, th, tr, uk, vi, zh-Hans, zh-Hant7778## 5. Displayed Category (@category_*)7980Only if adding a category shown in the app's search screen. Requires **three** coordinated file changes:8182### a) `data/categories.txt`83```84# First keyword should match [category_name] definition in strings.txt!85@category_name86en:Display Name|synonym87...translations...88```8990### b) `data/strings/strings.txt`91```92[category_name]93comment = Search category for ...; any changes should be duplicated in categories.txt @category_name!94tags = android-app,android-libs-car,apple-maps95en = Display Name96...translations for all supported locales...97```98The `en =` value must match the first keyword on the `en:` line (without prefix digit).99100### c) `libs/search/displayed_categories.cpp`101Add `"category_name"` to the `m_keys` initializer list.102103## 6. After Editing1041051. **Sort languages:**106 ```107 python3 tools/python/sort_categories.py --in-place108 ```1091102. **Build and run tests:**111 ```112 cmake --build build-agent --target search_tests && ctest -j --test-dir build-agent --stop-on-failure --output-on-failure -R search_tests113 ```1141153. **If a displayed category was added**, also run:116 ```117 cmake --build build-agent --target indexer_tests editor_tests && ctest -j --test-dir build-agent --stop-on-failure --output-on-failure -R "indexer_tests|editor_tests"118 ```