Select current word in Writer and lookup in Google

I want to have a macro so that when the cursor is in a word, it will select the word and look it up in Google (using system default browser). When a word or phrase is already selected, then it will look up in Google straight away after trimming whitespace before and after. The macro should work with any language script, not just Latin characters.