Changing URLs within text portion

Is there any way to create something for this; I have text for SEO in english with links to my english webshop's collections. I translate the file into, lets say, spanish, and I would like to search for any links in the text and replace the links within the text to the corresponding spanish collection. The file gets translated and the keywords, marked as links would not need to be changed, only the URL 'behind'.

Is this in any way possible, please explain in, if possible, simple terms, I am new :slight_smile:.

1 Like

Hi @rusc and welcome to the forum.
Quick question - where do you have the translated text? is it a Google Doc, or some other app?

Yes, it is in Google Docs

Unfortunately, currently, there is no easy way to do this.
We're actively working on a feature that would make this much easier.
Handling this in Google Docs is another complicaiton, but one the above feature is available, I'll walk you through the process.

1 Like

Would it be possible to scan a text for keywords and place links on a specified set of keywords? :smiley:

Hi @rusc can you give an example of 1. the input text, 2. the keyword and then 3. the expected output text?

Hi @Gaurang_Tandon i have listed an example below

  1. Here you'll find sunglasses with a twist of style and a fun attitude.
  2. Sunglasses being the keyword
  3. Here you'll find sunglasses with a twist of style and a fun attitude.

I think what you are describing is not possible as of now in just one step. However, you can do a two step process:

  1. Create a snippet that attaches the link command on those keywords, like this:

Text: {formtext: name=text; default=abcdefgh}
Keyword: {formtext: name=keyword; default=b}
Output:
{=replace(text, keyword, "{link: https://google.com}" & keyword & "{endlink}")}

  1. Copy and paste the output into a new snippet. It will have the links correctly setup.
  2. When you trigger this new snippet, it will insert your links as expected.
1 Like

Might be dumb but here goes, say I have to use this text in a google doc, how do i change from {link:} {endlink} to a userfriendly link

There is no dynamic way to directly create that link, which is why I have suggested the two-step process.

When you run the new snippet in the second step, it will render as a user-friendly link. Here's a preview of that second snippet:

a{link: https://google.com}b{endlink}cdefgh

(It will render cleanly without that tooltip)

1 Like

Could you modify the snippet to enable multiple keywords and multiple links.

I imagine something like:
Text
Keyword 1
Keyword 1 link
Keyword 2
Keyword 2 link

output

Sure. Here you go:

Text: {formtext: name=text; default=alpha beta gamma}

Keywolrds: {formtext: name=keywords; default=["alpha", "gamma"]}
Links: {formtext: name=links; default=["https://blaze.today", "https://google.com"]}
{if: count(links) == count(keywords)}
Making {=count(links)} replacements.
Output: {=reduce(links, text, (acc, link, index) -> replace(acc, keywords[index], link))}
{endif}

1 Like

this however, replaces the keyword with the link instead of {link: https://google.com/}" & keyword & "{endlink}
What would it look like if i wanted to keep that function?

I see. Try this updated snippet instead:

Text: {formtext: name=text; default=alpha beta gamma}

Keywords: {formtext: name=keywords; default=["alpha", "gamma"]}
Links: {formtext: name=links; default=["https://blaze.today", "https://google.com"]}
{if: count(links) == count(keywords)}
Making {=count(links)} replacements.
Output: {=reduce(links, text, (acc, link, index) -> replace(acc, keywords[index], "{link: " & link & "}" & keywords[index] & "{endlink}"))}
{endif}