I’m looking into language translation in Frontity. I am trying to create the functionality to select a language from a dropdown in the navigation, and the site is automatically translated by Google. I saw this post Multi-language website with frontity, but it doesn’t quite match what I am looking for. I don’t want to have a separate site that’s in a different language. It would need to be my original site as it’s tons of content, and cannot be duplicated for each translation, that would take forever.
Welcome to the Frontity community. Great to see that you’re using Frontity for your project.
How are you planning to do the translation? Do you intend to use the Google Translate API? If so then I guess one way to do this is to use the
Html2React package and use a processor to target each
<p> node and translate it to a language based on a setting stored in the state when the user selects a language from the dropdown.
For more on the
Html2React package see our docs here.
Although it’s doing something different you can take a look at this repo to see an example of
Html2React in action.
Hope this helps.
Hi! Yes, i am planning on using Google Translate API. I will take a look into those resources. thank you
@mburridge I am curious how translation in being handled for the Community forum here. I see that it is not being managed via a “Second site” that is already in each language like in the link in my initial question. Do you know how the language was handled for this forum?
I’m not sure what you mean. As far as I’m aware there’s no translations being managed on this forum. We conduct all our conversations in English, but if someone posts in another language then the post just appears in that language.
Well, for example, in the account preferences, you can change the language that you view the site in:
Oh I see! I use English so I’d never checked that setting!
TBH I’m not sure how that works. Our forum is hosted on Discourse so I guess that’s something they’ve implemented.
ah ok, maybe that is what’s handling it then. ok, thanks for the response!
Hi @maddogdev, regarding your question on how translation in being handled in the community forum, this post might help:
Hi @Reyes. Thanks for the input. Do you have a resource on how exactly the Google Translate API was integrated? Were you able to use the @google-cloud/translate package? (I was not able to get that work) Or did you do it some other way?
@SantosGuillamot was the one who added support for translations. Maybe he can point you in the right direction or provide you with some other resources.
@SantosGuillamot ah ok, thank you. so it’s not being done using Frontity in any way?
No, we aren’t using Frontity for the forum. But it should be possible to implement something similar in a Frontity project.