burki
burki

Reputation: 2996

iPhone - Multilingual search

I'm developing an iPhone application which supports multiple languages. There is quite a lot of data, in particular images. At the first launch of the application I create a NSManagedObject for each data element. Let's say, I have a NSManagedObject that stores a specific image (i.e. image path name) and a specific key for that image. The key is at the same time the name of the image (Example: I have an image of the Eiffel tower in Paris, so the key would be "Eiffel Tower").

In addition to that, I want to implement a search. If you search for "Eiffel tower", the image with the Eiffel tower in Paris should be shown. Up to this point everything works perfect.

Like you may have noticed, the image keys are in English. If I do the search directly on the image key, only English will be supported. I know I can't do the search on the image key. I'm familiar with NSLocalizedString, but there you have a key, and with that key you can get the expression in the right language. So I thought of kind a "reverse NSLocalizedString" function, where you have the final expression, let's say in French (Tour Eiffel), and on the basis of that expression you can get the original image key so that you can display the right image. Does exist such a function or do I need to code something on my own? I'd be very happy if you could tell what are the right strategies and how you do it in your own applications.

Upvotes: 1

Views: 92

Answers (1)

Christian Beer
Christian Beer

Reputation: 2025

In an app I built, I had a search entity with a searchable field and an objectID. Then I added all texts in each language as instances of that entity. Then I could search in that one "table". This way I could also add synonyms or other keywords to it.

Think of it as a kind of search index.

Upvotes: 1

Related Questions