Translate UITextField input text into Spanish runtime - ios

An iOS app which displaying wordpress blogs. There is search feature, App searches world-phress into API's data. Wordpress website contents are in Spanish language.
My issue is when user inputted text "Buho", app should search "Búho", "Buho", "buho", "búho" in Spanish data and display result according. Curretnly app is matching word "buho", not "búho".
On Wordpress website, same thing is possible, User can search either "Búho" or "Buho", all search result displayed.
How to translate UITextField's text value into Spanish, So I can easily search into NSArray and show result. Or is it possible to replace character set?
Simple english word searching is possible using NSArray filter, search into blog's title and text with particular text.
Like this:
let searchingWorld = self.searchBar.text!.lowercased()
let blogSearchResult = self.blogs.filter{ $0.title.lowercased().contains(searchingWorld) || $0.text.lowercased().contains(searchingWorld) || $0.tags.contains(searchingWorld) || $0.categories.contains(searchingWorld) }
self.blogs object is array of dictionary type object. {title, text, category, tags}
Not found any solution.
Any help greatly appreciated.
Punita

If I understand you correctly, you're not looking to translate to Spanish, but are looking how to do a so called diacritic insensitive search.
iOS has a search option to do that.
In the same way you can specify an option to do a case insensitive search.
Here're is an example that I hope helps.

Related

How does Twitter determine the spelling of trending hashtags?

I am trying to build a hashtag system which is similar to Twitter hashtags for an app. However, I cannot figure out how to spell such tags, when grouping different spellings together.
As an example, when you use #abc on Twitter there might be different spellings like #abc, #Abc, #aBC, etc.
When a hastag is trending it is displayed with a certain spelling in the trending list, eg. #abC and groups all different versions.
How should I determine the "correct" spelling?
I just built a hashtag system for my application and I'm not completely finished with it but my method was to get any posts that had a string of #*. Then parse that out with
GetHashes(t: string){
var hashed = t.match(/#\w+/g);
if(hashed != null){
hashed.forEach(element => {
var unhashed = element.slice(0,0) + element.slice(1,element.length);
this.hashTags.push(unhashed);
});
}else{
}
}
Then once I have all the hashes, I simply do a replace to translate everything into lowercase. That is what I send to the database. I'm using Firebase so I'm denormalizing my data and duplicating it a ton so I store the entire content of the post under the tag in the database. This might seem like a lot of data storage waste but storage is cheap. Then I don't have to implement a search system like "ElasticSearch" or "Algolia" which is expensive. (I still need to for full text search but not for hashes saving me a lot of cash).
Then when I want to return all #* I simply find that reference in the Firebase Database and viola!
What I can't figure out is how to make my hashtags links that call a function dynamically. I've been using innerHtml but that makes everything a string.
Hope this helps a bit.

How to prevent the user to write anything but English Ios

I have an iOS app and I want to prevent the user from entering anything other than English characters in a textfield.
If not, is there a way I can convert the non-English characters into English characters.
Thanks in advance
It looks like this answer has been addressed in this previous post:
How do I restrict UITextField to English only? (Stopping Chinese pinyin input)
Wherein the suggestion is made, by user k_ppes, to use the following code:
tf.keyboardType = UIKeyboardType.ASCIICapable

How to make a customer keyboard insert attributed text (e.g., website link) in Swift?

I'm making a 3rd-party keyboard for the iPhone, and can get the keyboard to insert a specific string via:
(textDocumentProxy as UIKeyInput).insertText("\(string)")
Unfortunately the insertText function only takes a string argument - is there a way to make it take an NSAttributedString, or a workaround that allows me to put an NSAttributedString into the text field the user is typing into?
I basically want part of "string" to be the URL of my app on the app store.
Unfortunately this is not possible. You can only insert String / NSString objects from a keyboard extension.
One common workaround is to put it in
[UIPasteboard generalPasteboard];
but this relies on the user then long-pressing and pasting it into the text field themselves, which is a horrible UX and seems like overkill for your use-case. Maybe it would be sufficient to include the 'https://' in the URL and then the app the user is typing in should hopefully detect that it's a link and display it as such. That's not guaranteed though.

How to reference a string of text then hyperlink it to a url?

My problem is i need a bit of code to reference a tracking number eg 1193849302, and insert it into a url http://www.example.com/track=[tracking number], so that the [tracking number] is replaced by 1193849302
then to have showing only the tracking number which is hyperlinked to said URL, i.e. 1193849302 (hyperlinked)
Either in html or javascript I think most of the site is CSS based though
Is this possible?
Thanks in advance
Edit maybe i should explain what i want a bit better
I have a customer area on a retail website , which returns the customers parcels tracking number when despatched.
What i'm after is a way to turn this tracking number into a working hyperlink which when clicked opens a new window into the couriers website automatically pushing the tracking number into the url and tracking the parcel for them.
Does this sound possible??
Most languages have a String.replace function.
For example, in Javascript, use replace() for this. Note that it takes a regex as an argument, so the [] need to be escaped:
var str = "http://www.example.com/track=[tracking number]";
str = str.replace("\[tracking number\]", "1193849302");
use String.replace method
The replace() method searches a string for a specified value, or a regular expression, and returns a new string where the specified values are replaced.
var str="http://www.example.com/track=[tracking number]";
var n=str.replace("tracking number","1193849302");
You can find more informations at http://www.w3schools.com/jsref/jsref_replace.asp

iOS NSString - Creating upper case based on locale

My iOS application has language selection option.
Its a server based application that receives all the strings from server that are to be displayed in the app.
In one of the view, i've to convert text to "upper case", for that I'm using NSString's upperCaseString method. This is working good for English. But for other languages like French, Chinese, Russian, German etc, it might create problem. So, I've to use "uppercaseStringWithLocale" to provider appropriate upper case string.
My question is how to create the NSLocate and pass it to "upperCaseStringWithLocale" method based on the language name. I know what's the language of the app that user has selected. Can I create locale object based on language name.?
I think you are looking for:
NSString *theLocaleIdentifier = #"es_ES_PREEURO";
[[NSLocale alloc] initWithLocaleIdentifier:theLocaleIdentifier];

Resources