Skip to content

POI multilingual categories #1819

Closed

Description

@Juanjo-MC

Currently, POI category names are monolingual. Because of this, the user experience of applications targeting a global audience is bad, as they are often presented with categories lists written in languages they do not understand.
A multilingual category system would allow to automatically match the user's device or application locale. This would significantly increase the overall value of Mapsforge POI databases.

Currently, the poi_categories table handles category names as a flat, monolingual TEXT string. I think that multilingual categories can be implemented with no changes to the database schema and little changes on the 'reader' side by storing a serialized localization object as JSON text on poi_categories.name field.
More substantial changes will probably be needed on the POI writer side.

The serialized JSON text can look something like this:

{
  "en": "Restaurant",
  "es": "Restaurante",
  "fr": "Restaurant",
  "de": "Restaurant",
  "it": "Ristorante"
}

On AbstractPoiCategoryManager.java, this query SELECT * FROM poi_categories ORDER BY id will become:

SELECT
	id,
	coalesce(name ->> ?, name ->> ?) AS name,
	parent
FROM 
	poi_categories
ORDER BY
	id

where the first parameter is the client app requested language (i.e fr) and the second one is the fallback one (i.e. en).

On metadata table, two rows must be added:

  • categories_default_language: the fallback language when a translation is missing. Database providers must ensure that translations into this language are present for all the records of the poi_categories table.
    There is no need to expose this value to client applications; it's for internal use only and must always be used as the second parameter of the above query.

  • categories_available_languages: a comma separated list of all the language codes available in the database. This will allow applications to discover available languages.
    Not all of the categories need to provide translations for all the languages. For example, provided that en is the categories_default_language, fr and de translations can be omitted from the JSON example above because "Restaurant" is spelled the same way in English, French, and German.

Activity

  1. changed the title [-]POI POI Multilingual categories[/-] [+]POI multilingual categories[/+] on Sep 25, 2026
  2. devemux86 commented on Sep 25, 2026

    @devemux86
    Collaborator

    @Juanjo-MC Thanks for the suggestion,some quick thoughts:

    1. We first need the 1st step that is the writer changes.

    2. Then comes the 2nd step that is the reader changes.
      Important: reader should be able to read old POI, like now.

    We need all category names translated in popular languages (beyond the default English):
    de, es, fr, it, nl
    German, Spanish, French, Italian, Dutch

    These translations must be stored somewhere, so poi-writer can read them and write them in the new poi files.
    Probably stored in the poi-mapping.xml file.

    We may need (?) a new version in the POI as there would be changes in the poi_categories table format.

  3. devemux86 commented on Sep 25, 2026

    @devemux86
    Collaborator

    Reminder: if we make changes in the poi-mapping.xml format, then we need to also update the poi-mapping.xsd xml schema.

  4. Juanjo-MC commented on Sep 25, 2026

    @Juanjo-MC
    Author

    These translations must be stored somewhere, so poi-writer can read them and write them in the new poi files.
    Probably stored in the poi-mapping.xml file.

    That's the natural place for them

    We may need (?) a new version in the POI as there would be changes in the poi_categories table format.

    Yes, we need a version bump here, because even though the database schema remains unchanged, the semantics of the poi_categories.name field are changing

  5. devemux86 commented on Sep 26, 2026

    @devemux86
    Collaborator

    categories_default_language

    This is not needed, default language is English like now.

    categories_available_languages

    Better to be: category_languages

    This should also be a new option in the map-writer command line.

  6. Juanjo-MC commented on Sep 26, 2026

    @Juanjo-MC
    Author

    categories_default_language

    This is not needed, default language is English like now.

    Well, you are talking about your databases here ;-) We cannot assume that every POI database will use English as its default language, nor should we force database providers to use English everywhere.

    Moreover, because of this requirement:

    Database providers must ensure that translations into this language are present for all the records of the poi_categories table.

    categories_default_language should not only be stored in the POI database; it should also be defined in poi-mapping.xml, so the POI writer knows which translation is mandatory when generating the database.

    Better to be: category_languages

    Fine with me.

    This should also be a new option in the map-writer command line.

    What exactly would this option control?

  7. devemux86 commented on Sep 26, 2026

    @devemux86
    Collaborator

    We are talking about the category names.
    Not the poi names that already exist in poi databases in all available OSM languages.

    Category names must have the existing English language as default like now.
    This feature request is to add extra translations for category names.

    What exactly would this option control?

    Poi writer must know from somewhere what category languages it should find in poi-mapping and store in poi files.


    Anyway all these are just thoughts, someone must start working on the code and then we will see the real requirements.

    Also all category names in poi-mapping.xml must be translated. 🙂

  8. devemux86 commented on Sep 26, 2026

    @devemux86
    Collaborator

    We cannot assume that every POI database will use English as its default language, nor should we force database providers to use English everywhere.

    Now I understand better what you mean; in that case, we probably need to set the default language as option.
    Again this is for category names.

    Then category_default_language and category_available_languages could work.

  9. Juanjo-MC commented on Sep 26, 2026

    @Juanjo-MC
    Author

    We are talking about the category names.
    Not the poi names that already exist in poi databases in all available OSM languages.

    Category names must have the existing English language as default like now.
    This feature request is to add extra translations for category names.

    Image

    From a database of mine.

    Again, we cannot assume that every POI database will use English as its default language, nor should we force database providers to use English everywhere.

    Mapsforge POI format is flexible enough to accommodate data in any language and, by the way, from many data sources, not only OSM.
    The data source for the database shown above is Spanish IGN.

  10. Juanjo-MC commented on Sep 26, 2026

    @Juanjo-MC
    Author

    More about this:

    Not all of the categories need to provide translations for all the languages.

    The example I provided in the first post is one possible use case; there are others.
    Think, for example, about a POI database exclusively focused on shopping. One of the top categories would be:

    {
      "en": "Supermarkets",
      "fr": "Supermarchés",
      "es": "Supermercados"
    }

    and it's subcategories would be:

    { "en": "Carrefour" }
    { "en": "Lidl" }
    { "en": "Mercadona" }

    In this case we do not want to translate the brands.
    So, the fact that not all categories should be translated into all available languages is not something that we may tolerate, is something that we want.

    I say this, because when you say:

    What exactly would this option control?

    Poi writer must know from somewhere what category languages it should find in poi-mapping and store in poi files.

    I get the impression that POI Writer would expect to find translations to those languages for every single category.
    Is that the case?

  11. devemux86 commented on Sep 26, 2026

    @devemux86
    Collaborator

    How does the category_available_languages get its values?
    Unless we define it in poi-mapping.xml, like the category_default_language.

  12. Juanjo-MC commented on Sep 26, 2026

    @Juanjo-MC
    Author

    How does the category_available_languages get its values?
    Unless we define it in poi-mapping.xml, like the category_default_language.

    On poi-mapping.xml, we can do something like this:

    <default_language>en</default_language>
    
    <category title="Restaurants">
      <translation lang="es">Restaurantes</translation>
      <translation lang="it">Ristoranti</translation>
      <mapping tag="amenity=restaurant" />
    </category>
    
    <category title="Ice cream shops">
      <translation lang="es">Heladerías</translation>
      <translation lang="it">Gelaterie</translation>
      <translation lang="fr">Glaciers</translation>
      <mapping tag="amenity=ice_cream" />
      <mapping tag="shop=ice_cream" />
    </category>

    Language for title is default_language, English in this case.
    Note that there is no fr translation for 'Restaurants', as it spells the same as in English

    POI writer must maintain a list of available languages, default_language being at the top of it.
    When parsing the first category, es and it would be added to the list. When parsing the second one, fr would be added.
    At the end of the whole process, values in the list are written to category_available_languages

    Resulting JSON category names would be:

    {
      "en": "Restaurants",
      "es": "Restaurantes",
      "it": "Ristoranti"
    }
    
    {
      "en": "Ice cream shops",
      "es": "Heladerías",
      "it": "Gelaterie",
      "fr": "Glaciers"
    }

    And category_available_languages would be en,es,it,fr

  13. devemux86 commented on Sep 27, 2026

    @devemux86
    Collaborator

    How do you expect the coalesce to work?

    There is a function to find a category by its title, used in poi writer and reader.
    Such things must continue to work.

    For example see the PoiSearchViewer example.

  14. 7 remaining items

  15. devemux86 commented on Sep 29, 2026

    @devemux86
    Collaborator

    Regarding the multilingual support, how would you like the translation of the poi-mapping.xml file to be structured? If you can detail the required format and target languages, I can start working on it

    @troNpo Thanks for the offer.

    However, there is still nothing decided about the structure.

    We must first start working on the code and finalize the structure, and then we can proceed with the translations.

  16. troNpo commented on Sep 29, 2026

    @troNpo

    @troNpo Thanks for the offer.

    However, there is still nothing decided about the structure.

    We must first start working on the code and finalize the structure, and then we can proceed with the translations.

    Perfect, I will follow the thread in silence since I have no knowledge to contribute.
    I will translations in a standard format that can be reused in the future when you have the process resolved.
    I'll upload them here:
    https://github.com/troNpo/Poi-multilanguage
    In case it is useful

  17. devemux86 commented on Sep 29, 2026

    @devemux86
    Collaborator

    @troNpo Thanks, but better wait and translate directly the poi-mapping.xml file.

    Otherwise, someone would need to perform an excessive number of copy & paste operations.

    Also the translations should be sorted for better management and future expansion:
    de, es, fr, it, nl

  18. Juanjo-MC commented on Sep 29, 2026

    @Juanjo-MC
    Author

    Clients can retrieve the available category languages via a new field from PoiFileInfo, filled from metadata table.

    PoiCategory.getTitle() continues to work like now with the default language.

    Extend the PoiCategory interface with a new method for the preferred language:

    PoiCategory.getTitle(String language)

    So it works like the existing PointOfInterest.getName(String language).

    @Juanjo-MC Will you start working on all these?

    Please, have a look here.
    If OK for you I will submit a PR.

  19. devemux86 commented on Sep 30, 2026

    @devemux86
    Collaborator

    Please, have a look here.
    If OK for you I will submit a PR.

    Thanks, but these are 3 commits with minor changes that do not even compile.
    (change to an interface without implementations)

    A PR must include the complete feature, fully implemented and ready for production use.

  20. devemux86 commented on Sep 30, 2026

    @devemux86
    Collaborator

    I started working on this.

  21. Juanjo-MC commented on Sep 30, 2026

    @Juanjo-MC
    Author

    Thanks, but these are 3 commits with minor changes that do not even compile.
    (change to an interface without implementations)

    I didn't implemented the interface because I wanted to discuss the implementation with you before.
    How should we store the translations, as a string? As a map? Something else?

    A PR must include the complete feature, fully implemented and ready for production use.

    As I said on the Cruiser thread, by the time being, I have little to no spare time to implement this myself. Sorry

    I started working on this.

    Thank you for this, much appreciated.
    In my view, multilingual categories is the missing piece for Mapsforge POIs to be considered feature complete.

  22. devemux86 commented on Oct 8, 2026

    @devemux86
    Collaborator

    I finished the POI v5 with multilingual categories.

    It is currently in the poi branch: https://github.com/mapsforge/mapsforge/tree/poi
    (only tables poi_categories and metadata were changed)

  23. devemux86 commented on Oct 8, 2026

    @devemux86
    Collaborator

    @troNpo I see you translated the categories here. Very nice work! 👍

    I updated the poi-mapping.xml with all translations (fixing the formatting and adding some missing translations).
    If you make more changes, please use the latest poi-mapping.xml from here:
    https://github.com/mapsforge/mapsforge/blob/poi/mapsforge-poi-writer/src/main/config/poi-mapping.xml

  24. Juanjo-MC commented on Oct 8, 2026

    @Juanjo-MC
    Author

    poi-mapping.xml

    @devemux86, @troNpo,

    In the attached file, I have corrected some of the Spanish and French translations.

  25. devemux86 commented on Oct 8, 2026

    @devemux86
    Collaborator

    @Juanjo-MC Thanks, I updated the poi-mappping.xml in the poi branch.

    An updated example poi is here: andorra.poi.zip

  26. devemux86 commented on Oct 9, 2026

    @devemux86
    Collaborator

    For reasons of clarity and management, it is best to have translations in all languages ​​(as we do now),
    regardless of whether some languages ​​share the same translation with the default language.

  27. added this to the 0.31.0 milestone on Oct 9, 2026
  28. devemux86 commented on Oct 24, 2026

    @devemux86
    Collaborator

    Implemented with #1823

    POI v5 are available in Mapsforge server and mirror (fast).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions